當前位置: 首頁>>代碼示例>>Java>>正文


Java IntentSender類代碼示例

本文整理匯總了Java中android.content.IntentSender的典型用法代碼示例。如果您正苦於以下問題:Java IntentSender類的具體用法?Java IntentSender怎麽用?Java IntentSender使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IntentSender類屬於android.content包,在下文中一共展示了IntentSender類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onResult

import android.content.IntentSender; //導入依賴的package包/類
@Override
public void onResult(LocationSettingsResult result) {
    final Status status = result.getStatus();
    switch (status.getStatusCode()) {
        case LocationSettingsStatusCodes.SUCCESS:
            // All location settings are satisfied -> nothing to do
            callSuccessCallback();
            break;
        case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
            // 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
                status.startResolutionForResult(mActivity, REQUEST_CHECK_SETTINGS);
            } catch (IntentSender.SendIntentException e) {
                Log.e(TAG, "PendingIntent unable to execute request.", e);
                callErrorCallback();
            }
            break;
        case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
            Log.e(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog not created.");
            callErrorCallback();
            break;
    }
}
 
開發者ID:philiWeitz,項目名稱:react-native-location-switch,代碼行數:25,代碼來源:LocationSwitch.java

示例2: onReturn

import android.content.IntentSender; //導入依賴的package包/類
@Override
public void onReturn(Intent result) {
    switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
        case OpenPgpApi.RESULT_CODE_SUCCESS: {

            long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, NO_KEY);
            save(keyId);

            break;
        }
        case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {

            PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
            try {
                Activity act = (Activity) getContext();
                act.startIntentSenderFromChild(
                        act, pi.getIntentSender(),
                        requestCode, null, 0, 0, 0);
            } catch (IntentSender.SendIntentException e) {
                Log.e(OpenPgpApi.TAG, "SendIntentException", e);
            }
            break;
        }
        case OpenPgpApi.RESULT_CODE_ERROR: {
            OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
            Log.e(OpenPgpApi.TAG, "RESULT_CODE_ERROR: " + error.getMessage());

            break;
        }
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:32,代碼來源:OpenPgpKeyPreference.java

示例3: actionCreateFileForSync

import android.content.IntentSender; //導入依賴的package包/類
@OnClick(R.id.btCreateFileForSync)
public void actionCreateFileForSync() {
    try {
        MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
                .setMimeType("text/plain").build();
        IntentSender intentSender = Drive.DriveApi.newCreateFileActivityBuilder()
                .setInitialMetadata(metadataChangeSet)
                .setInitialDriveContents(null)
                .setActivityTitle("Create file for sync")
                .build(mGoogleApiClient);

        startIntentSenderForResult(intentSender, REQUEST_CODE_NEW_FILE, null, 0, 0, 0);
    } catch (Exception e) {
        Log.w(TAG, "Unable to send intent", e);
    }
}
 
開發者ID:claudiodegio,項目名稱:dbsync,代碼行數:17,代碼來源:BaseMainDbActivity.java

示例4: onConnectionFailed

import android.content.IntentSender; //導入依賴的package包/類
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    // Called whenever the API client fails to connect.
    Log.i(TAG, "GoogleApiClient connection failed: " + connectionResult.toString());
    if (!connectionResult.hasResolution()) {
        // show the localized error dialog.
        GoogleApiAvailability.getInstance().getErrorDialog(activity, connectionResult.getErrorCode(), 0).show();
        return;
    }
    // The failure has a resolution. Resolve it.
    // Called typically when the app is not yet authorized, and an
    // authorization
    // dialog is displayed to the user.
    try {
        connectionResult.startResolutionForResult(activity, CONNECTION_FAILED_POPUP);
    } catch (IntentSender.SendIntentException e) {
        Log.e(TAG, "Exception while starting resolution activity", e);
    }
}
 
開發者ID:SKT-ThingPlug,項目名稱:thingplug-app-android,代碼行數:20,代碼來源:GoogleDriveHandler.java

示例5: startIntentSenderForResultInner

import android.content.IntentSender; //導入依賴的package包/類
private void startIntentSenderForResultInner(IntentSender intent, String who, int requestCode,
                                             Intent fillInIntent, int flagsMask, int flagsValues,
                                             Bundle options)
        throws IntentSender.SendIntentException {
    try {
        String resolvedType = null;
        if (fillInIntent != null) {
            fillInIntent.migrateExtraStreamToClipData();
            fillInIntent.prepareToLeaveProcess(this);
            resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
        }
        int result = ActivityManagerNative.getDefault()
                .startActivityIntentSender(mMainThread.getApplicationThread(), intent,
                        fillInIntent, resolvedType, mToken, who,
                        requestCode, flagsMask, flagsValues, options);
        if (result == ActivityManager.START_CANCELED) {
            throw new IntentSender.SendIntentException();
        }
        Instrumentation.checkStartActivityResult(result, null);
    } catch (RemoteException e) {
    }
    if (requestCode >= 0) {
        // If this start is requesting a result, we can avoid making
        // the activity visible until the result is received.  Setting
        // this code during onCreate(Bundle savedInstanceState) or onResume() will keep the
        // activity hidden during this time, to avoid flickering.
        // This can only be done when a result is requested because
        // that guarantees we will get information back when the
        // activity is finished, no matter what happens to it.
        mStartedActivity = true;
    }
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:33,代碼來源:a.java

示例6: uninstall

import android.content.IntentSender; //導入依賴的package包/類
@Override
public void uninstall(String packageName, String callerPackageName, int flags, IntentSender statusReceiver, int userId) throws RemoteException {
    boolean success = VAppManagerService.get().uninstallPackage(packageName);
    if (statusReceiver != null) {
        final Intent fillIn = new Intent();
        fillIn.putExtra(PackageInstaller.EXTRA_PACKAGE_NAME, packageName);
        fillIn.putExtra(PackageInstaller.EXTRA_STATUS, success ? PackageInstaller.STATUS_SUCCESS : PackageInstaller.STATUS_FAILURE);
        fillIn.putExtra(PackageInstaller.EXTRA_STATUS_MESSAGE, PackageHelper.deleteStatusToString(success));
        fillIn.putExtra("android.content.pm.extra.LEGACY_STATUS", success ? 1 : -1);
        try {
            statusReceiver.sendIntent(mContext, 0, fillIn, null, null);
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:17,代碼來源:VPackageInstallerService.java

示例7: resolveResult

import android.content.IntentSender; //導入依賴的package包/類
private void resolveResult(Status status) {
    if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
        try {
            //status.startResolutionForResult(mActivity, RC_READ);
            startIntentSenderForResult(status.getResolution().getIntentSender(), RC_READ, null, 0, 0, 0, null);
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
            mCredentialsApiClient.disconnect();
            mAccountSubject.onError(new Throwable(e.toString()));
        }
    }
    else {
        // The user must create an account or sign in manually.
        mCredentialsApiClient.disconnect();
        mAccountSubject.onError(new Throwable(getString(R.string.status_canceled_request_credential)));
    }
}
 
開發者ID:pchmn,項目名稱:RxSocialAuth,代碼行數:18,代碼來源:RxSmartLockPasswordsFragment.java

示例8: onConnectionFailed

import android.content.IntentSender; //導入依賴的package包/類
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    DebugLog.logMethod();
    DebugLog.logMessage("ConnectionResult: " + connectionResult.toString());
    DebugLog.logMessage("ConnectionResult error: " + connectionResult.getErrorCode() + "\n" + connectionResult.getErrorMessage());
    if (!connectionResult.hasResolution()) {
        GoogleApiAvailability.getInstance()
                .getErrorDialog(getActivity(), connectionResult.getErrorCode(), 0)
                .show();
        return;
    }

    try {
        connectionResult.startResolutionForResult(getActivity(), Constants.CONNECTION_RESOLUTION_REQUEST_CODE);
        connectionFailed = true;
    } catch (IntentSender.SendIntentException e) {
        // Unable to resolve, message user appropriately
        e.printStackTrace();
        DebugLog.logMessage(e.getMessage());
        Utilities.showToast(getActivity(), getString(R.string.google_drive_no_resolution));
    }
}
 
開發者ID:darsh2,項目名稱:CouponsTracker,代碼行數:23,代碼來源:SettingsFragment.java

示例9: onPackageInstalled

import android.content.IntentSender; //導入依賴的package包/類
@Override
public void onPackageInstalled(String basePackageName, int returnCode, String msg,
                               Bundle extras) {
    final Intent fillIn = new Intent();
    fillIn.putExtra(PackageInstaller.EXTRA_PACKAGE_NAME, basePackageName);
    fillIn.putExtra(PackageInstaller.EXTRA_SESSION_ID, mSessionId);
    fillIn.putExtra(PackageInstaller.EXTRA_STATUS,
            installStatusToPublicStatus(returnCode));
    fillIn.putExtra(PackageInstaller.EXTRA_STATUS_MESSAGE,
            installStatusToString(returnCode, msg));
    fillIn.putExtra("android.content.pm.extra.LEGACY_STATUS", returnCode);
    if (extras != null) {
        final String existing = extras.getString("android.content.pm.extra.FAILURE_EXISTING_PACKAGE");
        if (!TextUtils.isEmpty(existing)) {
            fillIn.putExtra(PackageInstaller.EXTRA_OTHER_PACKAGE_NAME, existing);
        }
    }
    try {
        mTarget.sendIntent(mContext, 0, fillIn, null, null);
    } catch (IntentSender.SendIntentException ignored) {
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:23,代碼來源:VPackageInstallerService.java

示例10: onConnectionFailed

import android.content.IntentSender; //導入依賴的package包/類
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    if (mProgress != null) {
        mProgress.dismiss();
    }

    secureBkGDriveFolderPreference.setEnabled(false);
    if (connectionResult.hasResolution()) {
        try {
            connectionResult.startResolutionForResult(BackupRestorePreferenceFragment.this.getActivity(), ConstantValues.REQUEST_GDRIVE_AUTHORIZATION);
        } catch (IntentSender.SendIntentException e) {
            // Unable to resolve, message user appropriately
        }
    } else {
        GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), connectionResult.getErrorCode(), 0).show();
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:18,代碼來源:PreferenceActivity.java

示例11: onConnectionFailed

import android.content.IntentSender; //導入依賴的package包/類
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    if (mResolvingConnectionError) {
        return;
    } else if (connectionResult.hasResolution()) {
        try {
            mResolvingConnectionError = true;
            connectionResult.startResolutionForResult(this, REQUEST_RESOLVE_CONNECTION_ERROR);
        } catch (IntentSender.SendIntentException e) {
            // There was an error with the resolution intent. Try again.
            mGoogleApiClient.connect();
        }
    } else {
        // Show dialog using GoogleApiAvailability.getErrorDialog()
        showErrorDialog(connectionResult.getErrorCode());
        mResolvingConnectionError = true;
    }
}
 
開發者ID:cahergil,項目名稱:Farmacias,代碼行數:19,代碼來源:MainActivity.java

示例12: resolveConnectionFailure

import android.content.IntentSender; //導入依賴的package包/類
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity the Activity trying to resolve the connection failure.
 * @param client the GoogleAPIClient instance of the Activity.
 * @param result the ConnectionResult received by the Activity.
 * @param requestCode a request code which the calling Activity can use to identify the result
 *                    of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               int fallbackErrorMessage) {

    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.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, activity.getString(fallbackErrorMessage));
        }
        return false;
    }
}
 
開發者ID:AndreFCruz,項目名稱:feup-lpoo-armadillo,代碼行數:41,代碼來源:BaseGameUtils.java

示例13: resolveConnectionFailure

import android.content.IntentSender; //導入依賴的package包/類
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity the Activity trying to resolve the connection failure.
 * @param client the GoogleAPIClient instance of the Activity.
 * @param result the ConnectionResult received by the Activity.
 * @param requestCode a request code which the calling Activity can use to identify the result
 *                    of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               String fallbackErrorMessage) {

    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.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, fallbackErrorMessage);
        }
        return false;
    }
}
 
開發者ID:Magicrafter13,項目名稱:1946,代碼行數:41,代碼來源:BaseGameUtils.java

示例14: launchPendingIntent

import android.content.IntentSender; //導入依賴的package包/類
private void launchPendingIntent(CryptoResultAnnotation cryptoResultAnnotation) {
    try {
        PendingIntent pendingIntent = cryptoResultAnnotation.getOpenPgpPendingIntent();
        if (pendingIntent != null) {
            messageSecurityMvpView.startPendingIntentForCryptoPresenter(
                    pendingIntent.getIntentSender(), REQUEST_CODE_UNKNOWN_KEY, null, 0, 0, 0);
        }
    } catch (IntentSender.SendIntentException e) {
        Timber.e(e, "SendIntentException");
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:12,代碼來源:MessageSecurityPresenter.java

示例15: startIntentSenderFromChildFragment

import android.content.IntentSender; //導入依賴的package包/類
/**
 * Like {@link #startIntentSenderFromChild}, but taking a Fragment; see
 * {@link #startIntentSenderForResult(IntentSender, int, Intent, int, int, int)}
 * for more information.
 *
 * @hide
 */
public void startIntentSenderFromChildFragment(Fragment child, IntentSender intent,
                                               int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
                                               int extraFlags, @Nullable Bundle options)
        throws IntentSender.SendIntentException {
    startIntentSenderForResultInner(intent, child.mWho, requestCode, fillInIntent,
            flagsMask, flagsValues, options);
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:15,代碼來源:a.java


注:本文中的android.content.IntentSender類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。