@Override public void onResult(Status status) { if (status.isSuccess()) { Toast .makeText(getActivity(), R.string.location_req_success_msg, Toast.LENGTH_LONG) .show(); } else { Toast .makeText(getActivity(), status.getStatusMessage(), Toast.LENGTH_LONG) .show(); getActivity().finish(); } } });
boolean thingsPlumbBusted=true; switch(result.getStatus().getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: requestLocations(); result .getStatus() .startResolutionForResult(getActivity(), SETTINGS_REQUEST_ID); thingsPlumbBusted=false;
@Override public void onResult(@NonNull Status status) { if(!status.isSuccess()) { Log.d(TAG, "Fence could not be removed: " + status); } } });
public void onResult(Status status) { if (status.isSuccess()) { // Successfully registered } else if (status.hasResolution()) { // Google provides a way to fix the issue try { status.startResolutionForResult( AroundMeFragment.this.getActivity(), // your current activity used to receive the result LOCATIONSERVICES_RESOLUTION_RESULCODE); // the result code you'll look for in your onActivityResult method to retry registering } catch (IntentSender.SendIntentException e) { Log.e(YourApplication.LOG_TAG, "SimpleMapFragment start resolution failure: ", e); } } else { // No recovery. Weep softly or inform the user. Log.e(YourApplication.LOG_TAG, "SimpleMapFragment registering failed: " + status.getStatusMessage()); } } });
@Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { Log.i(TAG, "Subscribed successfully."); startService(getBackgroundSubscribeServiceIntent()); } else { Log.e(TAG, "Operation failed. Error: " + NearbyMessagesStatusCodes.getStatusCodeString( status.getStatusCode())); } } });
@Override public void onResult(@NonNull MediaChannelResult result) { int statusCode = result.getStatus().getStatusCode(); if (statusCode != CastStatusCodes.SUCCESS && statusCode != CastStatusCodes.REPLACED) { Log.e(TAG, "Seek failed. Error code " + statusCode + ": " + CastUtils.getLogString(statusCode)); } if (--pendingSeekCount == 0) { pendingSeekWindowIndex = C.INDEX_UNSET; pendingSeekPositionMs = C.TIME_UNSET; for (EventListener listener : listeners) { listener.onSeekProcessed(); } } } }
@Subscribe(threadMode = ThreadMode.MAIN) public void onDriveBackupFailed(DriveBackupFailure event) { dismissProgressDialog(); Status status = event.status; if (status.hasResolution()) { try { status.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE); } catch (IntentSender.SendIntentException e) { // Unable to resolve, message user appropriately onDriveBackupError(new DriveBackupError(e.getMessage())); } } else { GooglePlayServicesUtil.getErrorDialog(status.getStatusCode(), this, 0).show(); } }
/** * Callback invoked when PlaceAutocompleteFragment encounters an error. */ @Override public void onError(Status status) { Log.e(TAG, "onError: Status = " + status.toString()); Toast.makeText(this, "Place selection failed: " + status.getStatusMessage(), Toast.LENGTH_SHORT).show(); }
@Test public void testGooglePaymentException_isSerializable() { Status status = new Status(1, "Some status message"); GooglePaymentException exception = new GooglePaymentException("Some message", status); Parcel parcel = Parcel.obtain(); exception.writeToParcel(parcel, 0); parcel.setDataPosition(0); GooglePaymentException actual = GooglePaymentException.CREATOR.createFromParcel(parcel); assertEquals("Some message", actual.getMessage()); assertEquals("Some status message", actual.getStatus().getStatusMessage()); assertEquals(1, actual.getStatus().getStatusCode()); } }
private void handleSignInResult(GoogleSignInResult result) { if (BuildConfig.DEBUG) { Log.d(MCXApplication.LOG_TAG, "handleSignInResult:" + result.isSuccess() + " " + result.getStatus().getStatusCode() + result.getStatus().hasResolution()); } if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); User user = new User(); user.setProvider(PROVIDER_NAME); user.setProviderDisplayName("Google+"); user.setUserId(acct.getId()); user.setUserName(acct.getId()); user.setDisplayName(acct.getDisplayName()); user.setMail(acct.getEmail()); this.mUserHelper.setCurrentUser(user); if (this.mUserSessionCallback != null) { this.mUserSessionCallback.onLogin(); } } else { // Signed out, show unauthenticated UI. this.mUserSessionCallback.onLogout(); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); Log.i(TAG, "onActivityResult: "+result); Log.i(TAG, "onActivityResult: "+result.getStatus()); Log.i(TAG, "onActivityResult: "+result.getSignInAccount()); Log.i(TAG, "onActivityResult: "+result.isSuccess()); Log.i(TAG, "onActivityResult: "+result.toString()); if (result.isSuccess()) { // Google Sign In was successful, authenticate with Firebase GoogleSignInAccount account = result.getSignInAccount(); firebaseAuthWithGoogle(account); } else { // Google Sign In failed, update UI appropriately // [START_EXCLUDE] Toast.makeText(LoginActivity.this, "Error", Toast.LENGTH_SHORT).show(); Log.i(TAG, "onActivityResult: "+result.getStatus().getStatusMessage()); // [END_EXCLUDE] } hideProgress(); } } private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
@Override public void onError(Throwable e) { if (e instanceof StatusException) { Status status = ((StatusException) e).getStatus(); if (status.hasResolution()) { try { status.startResolutionForResult(MainActivity.this, CREDENTIAL_REQUEST_RC); } catch (IntentSender.SendIntentException e1) { Log.e(TAG, "STATUS: Failed to send resolution."); } } else { // The user must create an account or sign in manually. Log.e(TAG, "STATUS: Unsuccessful credential request."); } } }
@Override public Completable loginWithGoogle(final Activity activity) { return Single.create((SingleOnSubscribe<AuthCredential>) e -> { googleClient = new GoogleApiClient.Builder(activity) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleClient); activity.startActivityForResult(signInIntent, RC_GOOGLE_SIGN_IN); googleSignInCompleteListener = result -> { if(result.isSuccess()) { AuthCredential credential = GoogleAuthProvider.getCredential(result.getSignInAccount().getIdToken(), null); e.onSuccess(credential); } else { e.onError(new Exception(result.getStatus().toString())); } }; }).flatMapCompletable(authCredential -> signInWithCredential(activity, authCredential)); }
void startSettingsApiResolutionForResult(Status status, Activity activity) throws SendIntentException { status.startResolutionForResult(activity, RequestCode.SETTINGS_API); }
@Override public void onResult(@NonNull Status status) { if (status.isSuccess()) { Log.i(TAG, "Subscribed successfully."); } else { logAndShowSnackbar("Could not subscribe, status = " + status); mSubscribeSwitch.setChecked(false); } } });
@SuppressWarnings({"MissingPermission"}) private void registerLocationUpdates() { PendingResult<Status> result = LocationServices.FusedLocationApi .requestLocationUpdates( mGoogleApiClient, mRequest, this); result.setResultCallback(status -> { if (status.isSuccess()) { // Successfully registered } else if (status.hasResolution()) { // Google provides a way to fix the issue try { status.startResolutionForResult( SimpleMapFragment.this.getActivity(), // your current activity used to receive the result LOCATIONSERVICES_RESOLUTION_RESULCODE); // the result code you'll look for in your onActivityResult method to retry registering } catch (IntentSender.SendIntentException e) { Log.e(YourApplication.LOG_TAG, "SimpleMapFragment start resolution failure: ", e); } } else { // No recovery. Weep softly or inform the user. Log.e(YourApplication.LOG_TAG, "SimpleMapFragment registering failed: " + status.getStatusMessage()); } }); }
@Override public void onResult(DataApi.DataItemResult dataItemResult) { if (!dataItemResult.getStatus().isSuccess()) { Log.e(TAG, "buildWatchOnlyNotification(): Failed to set the data, " + "status: " + dataItemResult.getStatus().getStatusCode()); } } });
@Override public void onConnectionResult(String s, ConnectionResolution connectionResolution) { switch (connectionResolution.getStatus().getStatusCode()) { case ConnectionsStatusCodes.STATUS_OK: listener.onConnected(); break; case ConnectionsStatusCodes.STATUS_CONNECTION_REJECTED: Log.i(TAG, "Connection rejected"); break; case ConnectionsStatusCodes.STATUS_ERROR: Log.i(TAG, "Connection error"); break; } }
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RC_SIGN_IN) { final GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... params) { String token = null; try { token = GoogleAuthUtil.getToken(mContext, result.getSignInAccount().getAccount(), SCOPES); } catch (IOException | GoogleAuthException e) { e.printStackTrace(); } return token; } @Override protected void onPostExecute(String token) { GoogleSignInAccount acct = result.getSignInAccount(); mListener.onGoogleAuthSignIn(token, acct.getId()); } }; task.execute(); } else { mListener.onGoogleAuthSignInFailed(result.getStatus().getStatusMessage()); } } }