android.content.IntentSender#SendIntentException ( )源码实例Demo

下面列出了android.content.IntentSender#SendIntentException ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android-credentials   文件: MainActivity.java
/**
     * Called when the Load Hints button is clicked. Requests a Credential "hint" which will
     * be the basic profile information and an ID token for an account on the device. This is useful
     * to auto-fill sign-up forms with an email address, picture, and name or to do password-free
     * authentication with a server by providing an ID Token.
     */
    private void loadHintClicked() {
        HintRequest hintRequest = new HintRequest.Builder()
                .setHintPickerConfig(new CredentialPickerConfig.Builder()
                        .setShowCancelButton(true)
                        .build())
                .setIdTokenRequested(shouldRequestIdToken())
                .setEmailAddressIdentifierSupported(true)
                .setAccountTypes(IdentityProviders.GOOGLE)
                .build();

;
        PendingIntent intent = mCredentialsClient.getHintPickerIntent(hintRequest);
        try {
            startIntentSenderForResult(intent.getIntentSender(), RC_HINT, null, 0, 0, 0);
            mIsResolving = true;
        } catch (IntentSender.SendIntentException e) {
            Log.e(TAG, "Could not start hint picker Intent", e);
            mIsResolving = false;
        }
    }
 
源代码2 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public void startIntentSender(IntentSender intent, Intent fillInIntent,
        int flagsMask, int flagsValues, int extraFlags, Bundle options)
        throws IntentSender.SendIntentException {
    try {
        String resolvedType = null;
        if (fillInIntent != null) {
            fillInIntent.migrateExtraStreamToClipData();
            fillInIntent.prepareToLeaveProcess(this);
            resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
        }
        int result = ActivityManager.getService()
            .startActivityIntentSender(mMainThread.getApplicationThread(),
                    intent != null ? intent.getTarget() : null,
                    intent != null ? intent.getWhitelistToken() : null,
                    fillInIntent, resolvedType, null, null,
                    0, flagsMask, flagsValues, options);
        if (result == ActivityManager.START_CANCELED) {
            throw new IntentSender.SendIntentException();
        }
        Instrumentation.checkStartActivityResult(result, null);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码3 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public void startIntentSender(IntentSender intent, Intent fillInIntent,
        int flagsMask, int flagsValues, int extraFlags, Bundle options)
        throws IntentSender.SendIntentException {
    try {
        String resolvedType = null;
        if (fillInIntent != null) {
            fillInIntent.setAllowFds(false);
            resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
        }
        int result = ActivityManagerNative.getDefault()
            .startActivityIntentSender(mMainThread.getApplicationThread(), intent,
                    fillInIntent, resolvedType, null, null,
                    0, flagsMask, flagsValues, options);
        if (result == ActivityManager.START_CANCELED) {
            throw new IntentSender.SendIntentException();
        }
        Instrumentation.checkStartActivityResult(result, null);
    } catch (RemoteException e) {
    }
}
 
源代码4 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public void startIntentSender(IntentSender intent,
        Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
        throws IntentSender.SendIntentException {
    try {
        String resolvedType = null;
        if (fillInIntent != null) {
            fillInIntent.setAllowFds(false);
            resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
        }
        int result = ActivityManagerNative.getDefault()
            .startActivityIntentSender(mMainThread.getApplicationThread(), intent,
                    fillInIntent, resolvedType, null, null,
                    0, flagsMask, flagsValues);
        if (result == IActivityManager.START_CANCELED) {
            throw new IntentSender.SendIntentException();
        }
        Instrumentation.checkStartActivityResult(result, null);
    } catch (RemoteException e) {
    }
}
 
源代码5 项目: journaldev   文件: MainActivity.java
@Override
public void onResult(@NonNull CredentialRequestResult credentialRequestResult) {

    Status status = credentialRequestResult.getStatus();
    if (status.isSuccess()) {
        onCredentialRetrieved(credentialRequestResult.getCredential());
    } else {
        if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
            try {
                isResolving = true;
                status.startResolutionForResult(this, RC_READ);
            } catch (IntentSender.SendIntentException e) {
                Log.d(TAG, e.toString());
            }
        } else {

            showHintDialog();
        }
    }
}
 
源代码6 项目: Cashier   文件: InAppBillingV3VendorTest.java
@Test
public void purchaseFailsIfSignatureIsInvalid() throws RemoteException, IntentSender.SendIntentException {
    mockDependeniesForSuccessfulPurchaseFlow();

    InAppBillingV3Vendor vendor = new InAppBillingV3Vendor(api, TEST_PUBLIC_KEY);
    vendor.initialize(mock(Context.class), initializationListener);

    Product inappPurchase = Product
            .create(
                    InAppBillingConstants.VENDOR_PACKAGE,
                    "so.product.much.purchase",
                    "1",
                    "1",
                    "1",
                    "1",
                    false,
                    1);

    PurchaseListener purchaseListener = mock(PurchaseListener.class);
    vendor.purchase(activity, inappPurchase, "hello-cashier!", purchaseListener);

    vendor.onActivityResult(
            vendor.getRequestCode(),
            Activity.RESULT_OK,
            new Intent()
                    .putExtra(RESPONSE_CODE, BILLING_RESPONSE_RESULT_OK)
                    .putExtra(RESPONSE_INAPP_PURCHASE_DATA, VALID_PURCHASE_RECEIPT_JSON)
                    .putExtra(RESPONSE_INAPP_SIGNATURE, TEST_INVALID_PUBLIC_KEY));

    verify(purchaseListener, times(1)).failure(inappPurchase, new Vendor.Error(PURCHASE_SUCCESS_RESULT_MALFORMED, BILLING_RESPONSE_RESULT_ERROR));
}
 
源代码7 项目: LocationAware   文件: LocationAlarmActivity.java
@Override public void startResolutionForLocation(ResolvableApiException resolvable) {
  try {
    resolvable.startResolutionForResult((Activity) context, REQUEST_CHECK_SETTINGS);
  } catch (IntentSender.SendIntentException e) {
    e.printStackTrace();
  }
}
 
源代码8 项目: io2015-codelabs   文件: MainActivity.java
private void resolveSignInError() {
    if (mSignInIntent != null) {
        try {
            mSignInProgress = STATE_IN_PROGRESS;
            startIntentSenderForResult(mSignInIntent.getIntentSender(),
                    RC_SIGN_IN, null, 0, 0, 0);
        } catch (IntentSender.SendIntentException e) {
            mSignInProgress = STATE_SIGNING_IN;
            mGoogleApiClient.connect();
        }
    } else {
        // You have a Play Services error -- inform the user
    }
}
 
源代码9 项目: oversec   文件: GpgEncryptionParamsFragment.java
public void triggerRecipientSelection(int requestCode, Intent actionIntent) {
    PendingIntent pi = getGpgEncryptionHandler(getMView().getContext()).triggerRecipientSelection(actionIntent);
    if (pi != null) {
        try {
            getActivity().startIntentSenderForResult(pi.getIntentSender(), requestCode, null, 0, 0, 0);
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
            //TODO now what?
        }


    } else {
        //TODO really needed?   recipientsSelectedCallback.onRecipientsSelected(null);
    }
}
 
源代码10 项目: AndroidDemoProjects   文件: MainActivity.java
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if( !authInProgress ) {
        try {
            authInProgress = true;
            connectionResult.startResolutionForResult( MainActivity.this, REQUEST_OAUTH );
        } catch(IntentSender.SendIntentException e ) {
            Log.e( "GoogleFit", "sendingIntentException " + e.getMessage() );
        }
    } else {
        Log.e( "GoogleFit", "authInProgress" );
    }
}
 
源代码11 项目: android-location-example   文件: MapsActivity.java
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    /*
     * Google Play services can resolve some errors it detects.
     * If the error has a resolution, try sending an Intent to
     * start a Google Play services activity that can resolve
     * error.
     */
    if (connectionResult.hasResolution()) {
        try {
            // Start an Activity that tries to resolve the error
            connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST);
            /*
             * Thrown if Google Play services canceled the original
             * PendingIntent
             */
        } catch (IntentSender.SendIntentException e) {
            // Log the error
            e.printStackTrace();
        }
    } else {
        /*
         * If no resolution is available, display a dialog to the
         * user with the error.
         */
        Log.i(TAG, "Location services connection failed with code " + connectionResult.getErrorCode());
    }
}
 
源代码12 项目: aptoide-client   文件: LoginActivity.java
@Override
public void onConnectionFailed(@NonNull ConnectionResult result) {
    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
        } catch (IntentSender.SendIntentException ignore) {
            // The intent was canceled before it was sent.
        }
    }
}
 
private void startBuyIntent(final Activity activity,
                            final PendingIntent pendingIntent,
                            int requestCode) throws BillingException {

    IntentSender sender = pendingIntent.getIntentSender();
    try {
        activity.startIntentSenderForResult(sender, requestCode, new Intent(), 0, 0, 0);

    } catch (IntentSender.SendIntentException e) {
        throw new BillingException(Constants.ERROR_SEND_INTENT_FAILED, e.getMessage());
    }
}
 
源代码14 项目: Cashier   文件: InAppBillingV3VendorTest.java
@Test
public void purchaseFailsIfResponseCodeIsInvalid() throws RemoteException, IntentSender.SendIntentException, JSONException {
    mockDependeniesForSuccessfulPurchaseFlow();

    InAppBillingV3Vendor vendor = new InAppBillingV3Vendor(api, null);
    vendor.initialize(mock(Context.class), initializationListener);

    Product inappPurchase = Product
            .create(
                    InAppBillingConstants.VENDOR_PACKAGE,
                    "so.product.much.purchase",
                    "1",
                    "1",
                    "1",
                    "1",
                    false,
                    1);

    PurchaseListener purchaseListener = mock(PurchaseListener.class);
    vendor.purchase(activity, inappPurchase, null, purchaseListener);

    Intent intent = new Intent()
            .putExtra(RESPONSE_CODE, BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE)
            .putExtra(RESPONSE_INAPP_PURCHASE_DATA, VALID_PURCHASE_RECEIPT_JSON)
            .putExtra(RESPONSE_INAPP_SIGNATURE, "");

    vendor.onActivityResult(
            vendor.getRequestCode(),
            Activity.RESULT_OK,
            intent);

    verify(purchaseListener, times(1)).failure(inappPurchase, new Vendor.Error(PURCHASE_UNAVAILABLE, BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE));
}
 
源代码15 项目: InAppUpdater   文件: UpdateManager.java
private void startUpdate(AppUpdateInfo appUpdateInfo) {
    try {
        Log.d(TAG, "Starting update");
        appUpdateManager.startUpdateFlowForResult(
                appUpdateInfo,
                mode,
                getActivity(),
                UpdateManagerConstant.REQUEST_CODE);
    } catch (IntentSender.SendIntentException e) {
        Log.d(TAG, "" + e.getMessage());
    }
}
 
源代码16 项目: amiibo   文件: DriveFragment.java
@DebugLog
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (connectionResult.hasResolution()) {
        try {
            connectionResult.startResolutionForResult(getActivity(),
                    RESOLVE_CONNECTION_REQUEST_CODE);
        } catch (IntentSender.SendIntentException e) {
            // Unable to resolve, message user appropriately
        }
    } else {
        GooglePlayServicesUtil
                .getErrorDialog(connectionResult.getErrorCode(), getActivity(), 0).show();
    }
}
 
源代码17 项目: vocefiscal-android   文件: MapsActivity.java
@Override
public void onConnectionFailed(ConnectionResult connectionResult) 
{
	/*
	 * Google Play services can resolve some errors it detects.
	 * If the error has a resolution, try sending an Intent to
	 * start a Google Play services activity that can resolve
	 * error.
	 */
	if (connectionResult.hasResolution()) 
	{
		try 
		{
			// Start an Activity that tries to resolve the error
			connectionResult.startResolutionForResult(this, LocationUtils.CONNECTION_FAILURE_RESOLUTION_REQUEST);

			/*
			 * Thrown if Google Play services canceled the original
			 * PendingIntent
			 */

		} catch (IntentSender.SendIntentException e) 
		{
			// Log the error
			
		}
	} else 
	{
		// If no resolution is available, display a dialog to the user with the error.
		//Log.e(LocationUtils.APPTAG, String.valueOf(connectionResult.getErrorCode()));
	}

}
 
源代码18 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public void startIntentSender(IntentSender intent,
        Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
        throws IntentSender.SendIntentException {
    startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags, null);
}
 
源代码19 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public void startIntentSender(IntentSender intent,
        Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
        throws IntentSender.SendIntentException {
    startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags, null);
}
 
源代码20 项目: flowless   文件: InternalContextWrapper.java
@TargetApi(16)
@Override
public void startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options)
        throws IntentSender.SendIntentException {
    activity.startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags, options);
}
 
 方法所在类
 同类方法