public void onComplete(Task<Boolean> task) { try { setGooglePayAvailable(task.getResult(ApiException.class)); } catch (ApiException exception) { exception.getStatusCode(); setGooglePayAvailable(false); } } });
public void onComplete(@NonNull Task<Boolean> task) { try { boolean result = task.getResult(ApiException.class); mProgressBar.setVisibility(View.INVISIBLE); if(result) { Toast.makeText(PayWithGoogleActivity.this, "Ready", Toast.LENGTH_SHORT).show(); mPayWithGoogleButton.setEnabled(true); } else { Toast.makeText(PayWithGoogleActivity.this, "No PWG", Toast.LENGTH_SHORT).show(); //hide Google as payment option } } catch (ApiException exception) { Toast.makeText(PayWithGoogleActivity.this, "Exception: " + exception.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } });
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) { try { GoogleSignInAccount account = completedTask.getResult(ApiException.class); firebaseAuthWithGoogle(account); } catch (ApiException e) { // The ApiException status code indicates the detailed failure reason. e.printStackTrace(); mPresenter.handleLoginFailure(e.getStatusCode(), e.getMessage()); } }
@Override public void onFailure(@NonNull Exception e) { // An error occurred while communicating with the service. mResult = null; if (e instanceof ApiException) { // An error with the Google Play Services API contains some additional details. ApiException apiException = (ApiException) e; Log.d(TAG, "Error: " + CommonStatusCodes.getStatusCodeString(apiException.getStatusCode()) + ": " + apiException.getStatusMessage()); } else { // A different, unknown type of error occurred. Log.d(TAG, "ERROR! " + e.getMessage()); } } };
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { GoogleSignInAccount account = task.getResult(ApiException.class); firebaseAuthWithGoogle(account); } catch (ApiException e) { Log.w(TAG, e.getMessage()); Toast.makeText(this, "Google Sign In failed. Please try again.", Toast.LENGTH_SHORT).show(); } } }
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) { try { GoogleSignInAccount account = completedTask.getResult(ApiException.class); firebaseAuthWithGoogle(account); Log.i(TAG, account.getDisplayName()); } catch (ApiException e) { // The ApiException status code indicates the detailed failure reason. // Please refer to the GoogleSignInStatusCodes class reference for more information. Log.w(TAG, "TAG:failed code=" + e.getStatusCode()); Toast.makeText(this, ":" + e.getStatusCode(), Toast.LENGTH_SHORT).show(); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { // Google Sign In was successful, authenticate with Firebase GoogleSignInAccount account = task.getResult(ApiException.class); if(account != null) { firebaseAuthWithGoogle(account); } } catch (ApiException e) { Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } } }
@Override public void onFailure(@NonNull Exception e) { int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case CommonStatusCodes.RESOLUTION_REQUIRED: Log.w(TAG, "Location settings not satisfied, attempting resolution intent"); try { ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(activity, REQUEST_CODE_LOCATION_SETTINGS); } catch (IntentSender.SendIntentException sendIntentException) { Log.e(TAG, "Unable to start resolution intent"); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: Log.w(TAG, "Location settings not satisfied and can't be changed"); break; } } });
@Override public void onFailure(@NonNull Exception e) { int statusCode = ((ApiException) e).getStatusCode(); if (statusCode == LocationSettingsStatusCodes .RESOLUTION_REQUIRED) { // Location settings are not satisfied, but this can // be fixed by showing the user a dialog try { // Show the dialog by calling // startResolutionForResult(), and check the // result in onActivityResult() ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult ((Activity) context, REQUEST_CODE); } catch (IntentSender.SendIntentException sendEx) { // Ignore the error } } } });
@Override public void onFailure(@NonNull Exception e) { // Extract the status code for the failure from within the Exception. int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case CommonStatusCodes.RESOLUTION_REQUIRED: try { // Display a user dialog to resolve the location settings // issue. ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(WhereAmIActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException sendEx) { Log.e(TAG, "Location Settings resolution failed.", sendEx); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: // Location settings issues can't be resolved by user. // Request location updates anyway. Log.d(TAG, "Location Settings can't be resolved."); requestLocationUpdates(); break; } } });
@Override public void onFailure(@NonNull Exception e) { // Extract the status code for the failure from within the Exception. int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case CommonStatusCodes.RESOLUTION_REQUIRED: try { // Display a user dialog to resolve the location settings // issue. ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(WhereAmIActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException sendEx) { Log.e(TAG, "Location Settings resolution failed.", sendEx); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: // Location settings issues can't be resolved by user. // Request location updates anyway. Log.d(TAG, "Location Settings can't be resolved."); requestLocationUpdates(); break; } } });
@Override public void onFailure(@NonNull Exception e) { // Extract the status code for the failure from within the Exception. int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case CommonStatusCodes.RESOLUTION_REQUIRED: try { // Display a user dialog to resolve the location settings // issue. ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(WhereAmIActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException sendEx) { Log.e(TAG, "Location Settings resolution failed.", sendEx); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: // Location settings issues can't be resolved by user. // Request location updates anyway. Log.d(TAG, "Location Settings can't be resolved."); requestLocationUpdates(); break; } } });
@Override public void onFailure(@NonNull Exception e) { // Extract the status code for the failure from within the Exception. int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case CommonStatusCodes.RESOLUTION_REQUIRED: try { // Display a user dialog to resolve the location settings // issue. ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(WhereAmIActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException sendEx) { Log.e(TAG, "Location Settings resolution failed.", sendEx); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: // Location settings issues can't be resolved by user. // Request location updates anyway. Log.d(TAG, "Location Settings can't be resolved."); requestLocationUpdates(); break; } } });
@Override public void onFailure(@NonNull Exception e) { // Extract the status code for the failure from within the Exception. int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case CommonStatusCodes.RESOLUTION_REQUIRED: // Location settings don't satisfy the requirements of the // Location Request, but they could be resolved through user // selection within a Dialog. try { // Display a user dialog to resolve the location settings issue. ResolvableApiException resolvable = (ResolvableApiException) e; resolvable.startResolutionForResult(LocationActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException sendEx) { Log.e(TAG, "Location Settings resolution failed.", sendEx); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: // Location settings don't satisfy the requirements of the // Location Request, however it can't be resolved with a user // dialog. // TODO Start monitoring location updates anyway, or abort. break; default: break; } } });
@Override public void onFailure(@NonNull Exception e) { int statusCode = ((ApiException) e).getStatusCode(); switch (statusCode) { case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: try { // Show the dialog by calling startResolutionForResult(), // and check the result in onActivityResult(). ResolvableApiException rae = (ResolvableApiException) e; rae.startResolutionForResult(BaseCreateActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException sie) { Toast.makeText(getApplicationContext(), "PendingIntent unable to execute request.", Toast.LENGTH_SHORT).show(); } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: String errorMessage = "Location settings are inadequate, and cannot be fixed here. Fix in Settings."; Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_LONG).show(); } updateLocationUI(); } });