GVKun编程网logo

【android】intent(android intent service)

5

本文将带您了解关于【android】intent的新内容,同时我们还将为您解释androidintentservice的相关知识,另外,我们还将为您提供关于Android4.4(KitKat)上的An

本文将带您了解关于【android】intent的新内容,同时我们还将为您解释android intent service的相关知识,另外,我们还将为您提供关于Android 4.4 (KitKat) 上的 Android Gallery 为 Intent.ACTION_GET_CONTENT 返回不同的 URI、android – 如何在Fragment中使用onNewIntent(Intent intent)方法?、android-无法解析的参考’Intent’:val intent = Intent、android.content.IntentSender.SendIntentException的实例源码的实用信息。

本文目录一览:

【android】intent(android intent service)

【android】intent(android intent service)

程序中各组件交互的方式

-------显示意图 指定activity名称--------

Intent intent = new Intent(this,第二个activity.class);
startActivity(intent);


-------------------隐式意图--------------
在配置文件,默认只给第一个页面加过滤器
application标签下
<activity android:name=".第二个activity">
<intent-filter>
<action android:name="com.itheima.main2(自定义)"/> //动作
<category android:name="android.intent.category.DEFAULT(默认)"/> //给动作的条件
</intent-filter>
</activity>

//应用
Intent intent = new Intent();
intent.setAction("com.itheima.main2(与动作匹配)");
intent.addCategory("android.intent.category.DEFAULT"(与category匹配));
startActivity(intent);


---------数据传递-----------------------------

Intent intent = new Intent(this,Activity02.class);
intent.putExtra("取名(key)",传递的数据);

在Activity02中

Intent intent = getIntent();
//若传的是String
String data = intent.getStringExtra(key);


--------数据回传(回传给上个activity)--------------------

//Activity01.class中
Intent intent = new Intent(this,Activity02.class);
//需要回传开启方法不同
startActivityForResult(intent,1);

//在Activity02.class中
Intent intent = new Intent();
intent.putExtra("key","value(这里假设String类型)");
setResult(1,intent);

//在Activity01.class中
protected void onActivityResult(int requestCode,int resultCode,Intent data){
super.onActivityResult(requestCode,resultCode,data);
if(requestCode==1){
if(resultCode==1){
Strib string = data.getStringExtra("key");
}
}

}

 

Android 4.4 (KitKat) 上的 Android Gallery 为 Intent.ACTION_GET_CONTENT 返回不同的 URI

在 KitKat 之前(或在新画廊之前)Intent.ACTION_GET_CONTENT返回一个这样的 URI

内容://媒体/外部/图像/媒体/3951。

使用ContentResolver和查询 MediaStore.Images.Media.DATA返回的文件 URL。

然而,在 KitKat 中,Gallery 会返回一个 URI(通过“Last”),如下所示:

内容://com.android.providers.media.documents/document/image:3951

我该如何处理?

android – 如何在Fragment中使用onNewIntent(Intent intent)方法?

android – 如何在Fragment中使用onNewIntent(Intent intent)方法?

@H_301_0@我正在尝试从我的设备中使用NFC硬件.但是,问题是当我注册Activity以接收Intent时:

@H_301_0@

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
@H_301_0@我在Activity中收到结果而不是片段.有没有办法在Fragment中处理这个结果?

@H_301_0@提前致谢!

解决方法:

@H_301_0@onNewIntent属于Activity,所以你不能在你的片段中拥有它.你可以做的是当数据到达onNewIntent时将数据传递给你的片段,前提是你有对片段的引用.

@H_301_0@

Fragment fragment;  
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    // Check if the fragment is an instance of the right fragment
    if (fragment instanceof MyNFCFragment) {
        MyNFCFragment my = (MyNFCFragment) fragment;
        // Pass intent or its data to the fragment's method
        my.processNFC(intent.getStringExtra());
    }

}

android-无法解析的参考’Intent’:val intent = Intent

android-无法解析的参考’Intent’:val intent = Intent

我敢肯定有些明显的东西,但是还没有找到解决这个简单问题的方法.错误发生在主要活动中,当用户猜测正确答案时,该活动试图启动另一个活动:

Error:(85, 23) Unresolved reference: Intent

该代码来自“ Android的Kotlin开发”一书中的高/低Android应用程序.

val intent = Intent("com.example.user.highlow2.CorrectGuessActivity")
startActivity(intent)

清单针对被调用活动具有以下意图过滤器:

<intent-filter>
    <action android:name="com.example.user.highlow2.CorrectGuessActivity"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

解决方法:

原始语法和建议均产生相同的错误. MainActivity需要以下内容才能识别Intent:
     导入android.content.Intent

android.content.IntentSender.SendIntentException的实例源码

android.content.IntentSender.SendIntentException的实例源码

项目:GodotGoogleService    文件:PlayService.java   
private void handleSignInResult(GoogleSignInResult m_result) {
    if (m_result.isSuccess()) {
        mAccount = m_result.getSignInAccount();
        succeedSignIn();
    } else {
        Status s = m_result.getStatus();

        Log.w(TAG,"SignInResult::Failed code="
        + s.getStatusCode() + ",Message: " + s.getStatusMessage());

        if (isResolvingConnectionFailure) { return; }
        if (!isIntentInProgress && m_result.getStatus().hasResolution()) {
            try {
                isIntentInProgress = true;

                activity.startIntentSenderForResult(
                s.getResolution().getIntentSender(),GOOGLE_SIGN_IN_REQUEST,null,0);
            } catch (SendIntentException ex) {
                connect();
            }

            isResolvingConnectionFailure = true;
        }
    }
}
项目:GodotFireBase    文件:GoogleSignIn.java   
@Override
public void onConnectionFailed(@NonNull ConnectionResult m_result) {
    Utils.d("Google:Connection:Failed");

    if (isResolvingConnectionFailure) { return; }
    if(!isIntentInProgress && m_result.hasResolution()) {
        try {
            isIntentInProgress = true;

            activity.startIntentSenderForResult(
            m_result.getResolution().getIntentSender(),Utils.FIREBASE_GOOGLE_SIGN_IN,0);

        } catch (SendIntentException ex) {
            isIntentInProgress = false;
            signIn();
        }

        isResolvingConnectionFailure = true;
        Utils.d("Google:Connection:Resolving.");
               }
}
项目:godot-gpgs    文件:Client.java   
public boolean resolveConnectionFailure(ConnectionResult result,int requestCode) {
    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity,requestCode);
            return true;
        } catch (IntentSender.SendIntentException e) {
            // The intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            googleapiclient.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();

        if (errorCode == ConnectionResult.INTERNAL_ERROR) {
            googleapiclient.connect();
        }

        GodotLib.calldeferred(instance_id,"_on_google_play_game_services_connection_Failed",new Object[] { });
        Log.i(TAG,"GPGS: onConnectionFailed error code: " + String.valueOf(errorCode));
        return false;
    }
}
项目:FMTech    文件:ehh.java   
public final void run()
{
  if (this.b.a()) {
    try
    {
      int i = 1 + (1 + this.c.f().b.a.d.f().indexOf(this.c) << 16);
      this.b.a(this.c.f(),i);
      return;
    }
    catch (IntentSender.SendIntentException localSendIntentException)
    {
      ehe.a(this.c);
      return;
    }
  }
  if (eer.b(this.b.c))
  {
    eer.a(this.b.c,this.c.f(),this.c,2,this.c);
    return;
  }
  ehe.a(this.c,this.a,this.b);
}
项目:zulip-android    文件:LoginActivity.java   
@Override
public void onConnectionFailed(ConnectionResult result) {
    if (commonProgressDialog.isShowing()) {
        // The user clicked the sign-in button already. Start to resolve
        // connection errors. Wait until onConnected() to dismiss the
        // connection dialog.
        if (result.hasResolution()) {
            try {
                result.startResolutionForResult(this,REQUEST_CODE_RESOLVE_ERR);
            } catch (SendIntentException e) {
                Log.e(TAG,e.getMessage(),e);
                // Yeah,no idea what to do here.
                commonProgressDialog.dismiss();
                Toast.makeText(LoginActivity.this,R.string.google_app_login_Failed,Toast.LENGTH_SHORT).show();
            }
        } else {
            commonProgressDialog.dismiss();
            if (!isNetworkAvailable()) {
                Toast.makeText(LoginActivity.this,R.string.toast_no_internet_connection,Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(LoginActivity.this,Toast.LENGTH_SHORT).show();
            }

        }
    }
}
项目:yelo-android    文件:GooglePlusManager.java   
/**
 * A helper method to flip the mResolveOnFail flag and start the resolution
 * of the ConnenctionResult from the Failed connect() call.
 */
private void startResolution() {

    try {
        // Don't start another resolution Now until we have a
        // result from the activity we're about to start.
        mResolveOnFail = false;
        // If we can resolve the error,then call start resolution
        // and pass it an integer tag we can use to track. This means
        // that when we get the onActivityResult callback we'll kNow
        // its from being started here.
        mConnectionResult
                        .startResolutionForResult(mActivity,CONNECTION_UPDATE_ERROR);
    } catch (final SendIntentException e) {
        // Any problems,just try to connect() again so we get a new
        // ConnectionResult.
        mPlusClient.connect();
    }
}
项目:tinytimetracker    文件:TinyTimeTracker.java   
public void purchaseIntent(String sku,int REQUEST_CODE) {
    if (mService == null) return;
    try {
        String developerPayload = "abcdefghijklmnopqrstuvwxyz";
        Bundle buyIntentBundle = mService.getBuyIntent(3,getPackageName(),sku,"inapp",developerPayload);
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(),REQUEST_CODE,new Intent(),Integer.valueOf(0),Integer.valueOf(0));
    } catch (remoteexception e1) {
        return;
    } catch (SendIntentException e2) {
        return;
    }
}
项目:365browser    文件:ActivityWindowAndroid.java   
@Override
public int showCancelableIntent(
        PendingIntent intent,IntentCallback callback,Integer errorId) {
    Activity activity = getActivity().get();
    if (activity == null) return START_INTENT_FAILURE;

    int requestCode = generateNextRequestCode();

    try {
        activity.startIntentSenderForResult(
                intent.getIntentSender(),requestCode,0);
    } catch (SendIntentException e) {
        return START_INTENT_FAILURE;
    }

    storeCallbackData(requestCode,callback,errorId);
    return requestCode;
}
项目:Weedsim    文件:StartActivity.java   
@Override
public void onConnectionFailed(ConnectionResult result) {
    if (!mIntentInProgress && result.hasResolution()) {
        try {
            mIntentInProgress = true;
            startIntentSenderForResult(result.getResolution()
                    .getIntentSender(),RC_SIGN_IN,0);
        } catch (SendIntentException e) {
            // The intent was canceled before it was sent. Return to the
            // default
            // state and attempt to connect to get an updated
            // ConnectionResult.
            mIntentInProgress = false;
            mGoogleapiclient.connect();
        }
    }
}
项目:cordova-fusedlocation    文件:FusedLocationHelper.java   
@Override
public void onResult(LocationSettingsResult locationSettingsResult) {
    final Status status = locationSettingsResult.getStatus();
    switch (status.getStatusCode()) {
        case LocationSettingsstatusCodes.SUCCESS:
            Log.i(TAG,"All location settings are satisfied.");
            GetLastLocation();
            break;
        case LocationSettingsstatusCodes.RESOLUTION_required:
            Log.i(TAG,"Location settings are not satisfied. Show the user a dialog to" +
                    "upgrade location settings ");

            try {
                // Show the dialog by calling startResolutionForResult(),and check the result
                // in onActivityResult().
                status.startResolutionForResult(mActivity,REQUEST_CHECK_SETTINGS);
            } catch (IntentSender.SendIntentException e) {                   
                ErrorHappened("PendingIntent unable to execute request.");
            }
            break;
        case LocationSettingsstatusCodes.SETTINGS_CHANGE_UNAVAILABLE:              
            ErrorHappened("Location settings are inadequate,and cannot be fixed here. Dialog " +
                    "not created.");
            break;
    }
}
项目:snake-game-aws    文件:LoginActivity.java   
private void resolveSignInError() {
    if (connectionResult.hasResolution()) {
        try {
            intentInProgress = true;
            startIntentSenderForResult(connectionResult.getResolution()
                    .getIntentSender(),0);
        } catch (SendIntentException e) {
            Log.i(LOG_TAG,"Sign in intent Could not be sent: "
                            + e.getLocalizedMessage());
            // The intent was canceled before it was sent. Return to the
            // default
            // state and attempt to connect to get an updated
            // ConnectionResult.
            intentInProgress = false;
            googleapiclient.connect();
        }
    }
}
项目:QuizUpWinner    文件:SettingsFragment.java   
public void onConnectionFailed(ConnectionResult paramConnectionResult)
{
  if (paramConnectionResult.hasResolution())
    try
    {
      ˎ localˎ = getActivity();
      getActivity();
      paramConnectionResult.startResolutionForResult(localˎ,9000);
      return;
    }
    catch (IntentSender.SendIntentException localSendIntentException)
    {
      this.mGoogleapiclient.connect();
      localSendIntentException.printstacktrace();
    }
}
项目:QuizUpWinner    文件:HomeActivityLocationHelper.java   
public void onConnectionFailed(ConnectionResult paramConnectionResult)
{
  if (this.activity == null)
    return;
  if (paramConnectionResult.hasResolution())
    try
    {
      paramConnectionResult.startResolutionForResult(this.activity,9000);
      return;
    }
    catch (IntentSender.SendIntentException localSendIntentException)
    {
      localSendIntentException.printstacktrace();
      return;
    }
  paramConnectionResult.getErrorCode();
}
项目:Little-Nibolas    文件:AndroidLauncher.java   
@Override
public void onConnectionFailed(ConnectionResult result) {
    if (mResolvingError) {
           // Already attempting to resolve an error.
           return;
       } else if (result.hasResolution()) {
           try {
               mResolvingError = true;
               result.startResolutionForResult(this,REQUEST_RESOLVE_ERROR);
           } catch (SendIntentException e) {
               // There was an error with the resolution intent. Try again.
               mGoogleapiclient.connect();
           }
       } else {
           // Show dialog using GooglePlayServicesUtil.getErrorDialog()
           showErrorDialog(result.getErrorCode());
           mResolvingError = true;
       }

}
项目:XamarinAdmobTutorial    文件:RetrieveContentsWithProgressDialogActivity.java   
@Override
public void onConnected(Bundle connectionHint) {
    super.onConnected(connectionHint);

    // If there is a selected file,open its contents.
    if (mSelectedFileDriveId != null) {
        open();
        return;
    }

    // Let the user pick an mp4 or a jpeg file if there are
    // no files selected by the user.
    IntentSender intentSender = Drive.DriveApi
            .newOpenFileActivityBuilder()
            .setMimeType(new String[]{ "video/mp4","image/jpeg" })
            .build(getGoogleapiclient());
    try {
        startIntentSenderForResult(intentSender,REQUEST_CODE_OPENER,0);
    } catch (SendIntentException e) {
      Log.w(TAG,"Unable to send intent",e);
    }
}
项目:XamarinAdmobTutorial    文件:CreateFileWithCreatorActivity.java   
@Override
public void onResult(ContentsResult result) {
    MetadataChangeSet MetadataChangeSet = new MetadataChangeSet.Builder()
            .setMimeType("text/html").build();
    IntentSender intentSender = Drive.DriveApi
            .newCreateFileActivityBuilder()
            .setinitialMetadata(MetadataChangeSet)
            .setinitialContents(result.getContents())
            .build(getGoogleapiclient());
    try {
        startIntentSenderForResult(
                intentSender,REQUEST_CODE_CREATOR,0);
    } catch (SendIntentException e) {
        Log.w(TAG,e);
    }
}
项目:GooglePlayServicesGameSample    文件:GamesClientHelperImpl.java   
private void handleConnectionResult(ConnectionResult result) {
    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity,REQUEST_START_RESOLUTION_FOR_RESULT);
        } catch (SendIntentException e) {
            Log.e(this.getClass().getSimpleName(),"unexpected exception for startResolutionForResult",e);
        }
        return;
    }
    listener.onError(result);
    Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
            result.getErrorCode(),activity,REQUEST_GET_ERROR_DIALOG);
    if (errorDialog != null) {
        errorDialog.show();
    }

}
项目:UbiNomadLib    文件:GoogleConnector.java   
public void resolveSignInError() {
    if (mSignInIntent != null) {
        try {
            mSignInProgress = STATE_IN_PROGRESS;
            ubiNomadActivity.startIntentSenderForResult(mSignInIntent.getIntentSender(),0);
        } catch (SendIntentException e) {
            Log.i(TAG,"Sign in intent Could not be sent: "
                    + e.getLocalizedMessage());
            // The intent was canceled before it was sent.  Attempt to connect to
            // get an updated ConnectionResult.
            mSignInProgress = STATE_SIGN_IN;
            mGoogleapiclient.connect();
        }
    } else {
        // Google Play services wasn't able to provide an intent for some
        // error types,so we show the default Google Play services error
        // dialog which may still start an intent on our behalf if the
        // user can resolve the issue.
        DialogFragment dialog = new GoogleSignInDialog();
        Bundle args = new Bundle();
        args.putInt("id",DIALOG_PLAY_SERVICES_ERROR);
        dialog.setArguments(args);
        dialog.show(ubiNomadActivity.getSupportFragmentManager(),"tag");
    }  
}
项目:barterli_android    文件:GooglePlusManager.java   
/**
 * A helper method to flip the mResolveOnFail flag and start the resolution
 * of the ConnenctionResult from the Failed connect() call.
 */
private void startResolution() {

    try {
        // Don't start another resolution Now until we have a
        // result from the activity we're about to start.
        mResolveOnFail = false;
        // If we can resolve the error,just try to connect() again so we get a new
        // ConnectionResult.
        mPlusClient.connect();
    }
}
项目:HereAStory-Android    文件:PinFileActivity.java   
/**
 * Starts a file opener intent to pick a file.
 */
@Override
public void onConnected(Bundle connectionHint) {
    super.onConnected(connectionHint);
    if (mFileId == null) {
        IntentSender intentSender = Drive.DriveApi
                .newOpenFileActivityBuilder()
                .setMimeType(new String[] {"application/octet-stream"})
                .build(getGoogleapiclient());
        try {
            startIntentSenderForResult(intentSender,0);
        } catch (SendIntentException e) {
            Log.w(TAG,e);
        }
    } else {
        DriveFile file = Drive.DriveApi.getFile(getGoogleapiclient(),mFileId);
        file.getMetadata(getGoogleapiclient()).setResultCallback(MetadataCallback);
    }
}
项目:HereAStory-Android    文件:RetrieveContentsWithProgressDialogActivity.java   
@Override
public void onConnected(Bundle connectionHint) {
    super.onConnected(connectionHint);

    // If there is a selected file,e);
    }
}
项目:HereAStory-Android    文件:CreateFileWithCreatorActivity.java   
@Override
public void onResult(ContentsResult result) {
    MetadataChangeSet MetadataChangeSet = new MetadataChangeSet.Builder()
            .setMimeType("text/html").build();
    IntentSender intentSender = Drive.DriveApi
            .newCreateFileActivityBuilder()
            .setinitialMetadata(MetadataChangeSet)
            .setinitialContents(result.getContents())
            .build(getGoogleapiclient());
    try {
        startIntentSenderForResult(
                intentSender,e);
    }
}
项目:HereAStory-Android    文件:ListenChangeEventsForFilesActivity.java   
/**
 * Forces user to pick a file on connection.
 */
@Override
public void onConnected(Bundle connectionHint) {
    if (mSelectedFileId == null) {
        IntentSender intentSender = Drive.DriveApi
                .newOpenFileActivityBuilder()
                .setMimeType(new String[] { "text/plain" })
                .build(getGoogleapiclient());
        try {
            startIntentSenderForResult(intentSender,e);
        }
    }
}
项目:HereAStory-Android    文件:BaseDriveActivity.java   
@Override
public void onConnectionFailed(ConnectionResult result) {
    Log.i(TAG,"Connection Failed: " + result.getErrorCode());
    if (!result.hasResolution()) {
        GooglePlayServicesUtil.showErrorDialogFragment(result.getErrorCode(),this,0);
        return;
    }
    // If user interaction is required to resolve the connection failure,the result will
    // contain a resolution.  This will launch a UI that allows the user to resolve the issue.
    // (E.g.,authorize your app.)
    try {
        result.startResolutionForResult(this,RESOLVE_CONNECTION_REQUEST_CODE);
    } catch (SendIntentException e) {
        Log.i(TAG,"Send intent Failed",e);
    }
}
项目:omni-note    文件:DriveActivity.java   
/**
 * Called when {@code mGoogleapiclient} is trying to connect but Failed.
 * Handle {@code result.getResolution()} if there is a resolution is
 * available.
 */
@Override
public void onConnectionFailed(ConnectionResult result) {
    Log.i(TAG,"Googleapiclient connection Failed: " + result.toString());
    if (!result.hasResolution()) {
        // show the localized error dialog.
        GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(),0).show();
        return;
    }
    try {
        result.startResolutionForResult(this,REQUEST_CODE_RESOLUTION);
    } catch (SendIntentException e) {
        Log.e(TAG,"Exception while starting resolution activity",e);
    }
}
项目:googleplayservices    文件:GooglePlayServices.java   
@Override public void onConnectionFailed (ConnectionResult result) {
 String errormessage = result.toString();
 Log.w (LOG_TAG,errormessage);
 connectionAttempts += 1;
 if (!result.hasResolution() || connectionAttempts >= 2) {
  Log.w (LOG_TAG,"Error: no resolution. Google Play Services connection Failed.");
  tryConnectCallback.error ("Error: " + errormessage + "."); tryConnectCallback = null;
  return;
 }
 try {
  result.startResolutionForResult (cordova.getActivity(),result.getErrorCode());
 } catch (SendIntentException e) {
  // There was an error with the resolution intent. Try again.
  mGoogleapiclient.connect ();
 }
}
项目:aws-mobile-self-paced-labs-samples    文件:LoginActivity.java   
private void resolveSignInError() {
    if (connectionResult.hasResolution()) {
        try {
            intentInProgress = true;
            startIntentSenderForResult(connectionResult.getResolution()
                    .getIntentSender(),"Sign in intent Could not be sent: "
                            + e.getLocalizedMessage());
            // The intent was canceled before it was sent. Return to the
            // default
            // state and attempt to connect to get an updated
            // ConnectionResult.
            intentInProgress = false;
            googleapiclient.connect();
        }
    }
}
项目:mtransit-for-android    文件:MTActivityWithGoogleapiclient.java   
@Override
public void onConnectionFailed(ConnectionResult result) {
    if (this.resolvingError) {
        return;
    }
    if (result.hasResolution()) {
        try {
            this.resolvingError = true;
            result.startResolutionForResult(this,REQUEST_RESOLVE_ERROR);
        } catch (SendIntentException sie) {
            MTLog.w(this,sie,"Error while resolving Google Play Services error!");
            Googleapiclient googleapiclient = getGoogleapiclientOrInit();
            if (googleapiclient != null) {
                googleapiclient.connect();
            }
        }
    } else {
        showErrorDialog(result.getErrorCode());
        this.resolvingError = true;
    }
}
项目:tensiontunnel    文件:MainActivity.java   
@Override
public void onConnectionFailed(ConnectionResult result)
{
    if ((!this.intentInProgress) && result.hasResolution())
    {
        try
        {
            this.intentInProgress = true;
            result.startResolutionForResult(this,MainActivity.REQUEST_RESOLVE_ERROR);
        }
        catch (SendIntentException e)
        {
            this.intentInProgress = false;
            this.apiclient.connect();
        }
    }
}
项目:go    文件:GamesApiActivity.java   
@Override
public void onConnectionFailed(ConnectionStatus status) {
  int errorCode = status.getErrorCode();
  if (status.hasResolution()) {
    try {
      // This usually happen when user needs to authenticate into Games API.
      status.startResolutionForResult(this,REQUEST_CODE_RECONNECT);
    } catch (SendIntentException e) {
      Log.e(TAG,"Unable to recover from a connection failure: " + errorCode + ".");
      this.finish();
    }
  } else {
    Log.e(TAG,"Did you install Gmscore.apk?");
    this.finish();
  }
}
项目:cursoAndroidUTN    文件:lay_google.java   
private void resolveSignInError()
{
    if (mConnectionResult.hasResolution())
    {
        try
        {
            mIntentInProgress = true;
            startIntentSenderForResult(mConnectionResult.getResolution().getIntentSender(),0);
        }
        catch (SendIntentException e)
        {
            // The intent was canceled before it was sent. Return to the
            // default
            // state and attempt to connect to get an updated
            // ConnectionResult.
            mIntentInProgress = false;
            mGoogleapiclient.connect();
        }
    }
}
项目:spots    文件:LoginActivity.java   
@Override
public void onClick(View view) {
    if (view.getId() == R.id.sign_in_button && !mPlusClient.isConnected()) {
        if (mConnectionResult == null) {
            mConnectionProgressDialog.show();
        } else {
            try {
                mConnectionResult.startResolutionForResult(LoginActivity.this,CONNECTION_FAILURE_RESOLUTION_REQUEST);
            } catch (SendIntentException e) {
                // Try connecting again.
                mConnectionResult = null;
                mPlusClient.connect();
            }
        }
    }
}
项目:spots    文件:LoginActivity.java   
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (mConnectionProgressDialog.isShowing()) {
        // The user clicked the sign-in button already. Start to resolve
        // connection errors. Wait until onConnected() to dismiss the
        // connection dialog.
        if (connectionResult.hasResolution()) {
          try {
                   connectionResult.startResolutionForResult(this,CONNECTION_FAILURE_RESOLUTION_REQUEST);
           } catch (SendIntentException e) {
                   mPlusClient.connect();
           }
        }
      }
      // Save the result and resolve the connection failure upon a user click.
      mConnectionResult = connectionResult;
}
项目:Allow    文件:LoginActivity.java   
@Override
public void onClick(View view) {
    if (view.getId() == R.id.sign_in_button && !mPlusClient.isConnected()) {
        if (mConnectionResult == null) {
            mPlusClient.connect();
            mProgress.setVisibility(View.VISIBLE);

        } else {
            try {
                mConnectionResult.startResolutionForResult(this,REQUEST_CODE_RESOLVE_ERR);
            } catch (SendIntentException e) {
                // Try connecting again.
                e.printstacktrace();
                mConnectionResult = null;
                connectGPlus();
            }
        }
    }
}
项目:Allow    文件:LoginActivity.java   
@Override
public void onConnectionFailed(ConnectionResult result) {
    if (mProgress.getVisibility() == View.VISIBLE) {
        // The user clicked the sign-in button already. Start to resolve
        // connection errors. Wait until onConnected() to dismiss the
        // connection dialog.
        if (result.hasResolution()) {
            try {
                result.startResolutionForResult(this,REQUEST_CODE_RESOLVE_ERR);
            } catch (SendIntentException e) {
                e.printstacktrace();
                connectGPlus();
            }
        }
    }
    // Save the result and resolve the connection failure upon a user click.
    mConnectionResult = result;
}
项目:jcertif-android-2013    文件:LoginFragment.java   
@Override
public void onConnectionFailed(ConnectionResult res) {
    if (mConnectionProgressDialog.isShowing()) {

        if (res.hasResolution()) {
            try {
                res.startResolutionForResult(this.getActivity(),REQUEST_CODE_RESOLVE_ERR);
            } catch (SendIntentException e) {
                mPlusClient.connect();
            }
        }
    }

    // Save the intent so that we can start an activity when the user clicks
    // the sign-in button.
    mConnectionResult = res;
}
项目:q-mail    文件:MessageViewFragment.java   
@Override
public void startPendingIntentForCryptoPresenter(IntentSender si,Integer requestCode,Intent fillIntent,int flagsMask,int flagValues,int extraFlags) throws SendIntentException {
    if (requestCode == null) {
        getActivity().startIntentSender(si,fillIntent,flagsMask,flagValues,extraFlags);
        return;
    }

    requestCode |= REQUEST_MASK_CRYPTO_PRESENTER;
    getActivity().startIntentSenderForResult(
            si,extraFlags);
}
项目:q-mail    文件:MessageViewFragment.java   
@Override
public void startIntentSenderForMessageLoaderHelper(IntentSender si,int requestCode,int extraFlags) {
    showProgressthreshold = null;
    try {
        requestCode |= REQUEST_MASK_LOADER_HELPER;
        getActivity().startIntentSenderForResult(
                si,extraFlags);
    } catch (SendIntentException e) {
        Timber.e(e,"Irrecoverable error calling PendingIntent!");
    }
}
项目:q-mail    文件:MessageCompose.java   
@Override
public void onMessagebuildreturnPendingIntent(PendingIntent pendingIntent,int requestCode) {
    requestCode |= REQUEST_MASK_MESSAGE_BUILDER;
    try {
        startIntentSenderForResult(pendingIntent.getIntentSender(),0);
    } catch (SendIntentException e) {
        Timber.e(e,"Error starting pending intent from builder!");
    }
}
项目:q-mail    文件:MessageCompose.java   
public void launchUserInteractionPendingIntent(PendingIntent pendingIntent,int requestCode) {
    requestCode |= REQUEST_MASK_RECIPIENT_PRESENTER;
    try {
        startIntentSenderForResult(pendingIntent.getIntentSender(),0);
    } catch (SendIntentException e) {
        e.printstacktrace();
    }
}

我们今天的关于【android】intentandroid intent service的分享就到这里,谢谢您的阅读,如果想了解更多关于Android 4.4 (KitKat) 上的 Android Gallery 为 Intent.ACTION_GET_CONTENT 返回不同的 URI、android – 如何在Fragment中使用onNewIntent(Intent intent)方法?、android-无法解析的参考’Intent’:val intent = Intent、android.content.IntentSender.SendIntentException的实例源码的相关信息,可以在本站进行搜索。

本文标签: