private void copeWithFailure(Exception e) { if (e instanceof ResolvableApiException) { try { ((ResolvableApiException)e).startResolutionForResult(this, REQUEST_RESOLUTION); return; } catch (IntentSender.SendIntentException e1) { e=e1; } } Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); Log.e(getClass().getSimpleName(), "Exception getting location", e); }
private void copeWithFailure(Exception e) { if (e instanceof ResolvableApiException) { try { ((ResolvableApiException)e).startResolutionForResult(this, REQUEST_RESOLUTION); return; } catch (IntentSender.SendIntentException e1) { e=e1; } } Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); Log.e(getClass().getSimpleName(), "Exception getting location", e); finish(); }
@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(); } });