com.google.android.gms.auth.GooglePlayServicesAvailabilityException Java Examples

The following examples show how to use com.google.android.gms.auth.GooglePlayServicesAvailabilityException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthTaskUrlShortener.java    From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
private void handleAuthException(final Activity activity, final Exception e) {
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (e instanceof GooglePlayServicesAvailabilityException) {
                // The Google Play services APK is old, disabled, or not present.
                // Show a dialog created by Google Play services that allows
                // the user to update the APK
                int statusCode = ((GooglePlayServicesAvailabilityException) e).getConnectionStatusCode();
                Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
                        statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR_FOR_URL_SHORTNER);
                dialog.show();
            } else if (e instanceof UserRecoverableAuthException) {
                // Unable to authenticate, such as when the user has not yet granted
                // the app access to the account, but the user can fix this.
                // Forward the user to an activity in Google Play services.
                Intent intent = ((UserRecoverableAuthException) e).getIntent();
                activity.startActivityForResult(
                        intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR_FOR_URL_SHORTNER);

            }
        }
    });
}
 
Example #2
Source File: AuthorizedServiceTask.java    From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void handleAuthException(final Activity activity, final Exception e) {
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (e instanceof GooglePlayServicesAvailabilityException) {
                // The Google Play services APK is old, disabled, or not present.
                // Show a dialog created by Google Play services that allows
                // the user to update the APK
                int statusCode = ((GooglePlayServicesAvailabilityException) e).getConnectionStatusCode();
                Dialog dialog;
                if(authScope.equals(AUTH_PROXIMITY_API)) {
                    dialog = GooglePlayServicesUtil.getErrorDialog(
                            statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR_FOR_PRX_API);
                } else {
                    dialog = GooglePlayServicesUtil.getErrorDialog(
                            statusCode, activity, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR_FOR_URL_SHORTNER);
                }
                dialog.show();
            } else if (e instanceof UserRecoverableAuthException) {
                // Unable to authenticate, such as when the user has not yet granted
                // the app access to the account, but the user can fix this.
                // Forward the user to an activity in Google Play services.
                Intent intent = ((UserRecoverableAuthException) e).getIntent();
                if(authScope.equals(AUTH_PROXIMITY_API)) {
                    activity.startActivityForResult(
                            intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR_FOR_PRX_API);
                } else {
                    activity.startActivityForResult(
                            intent, REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR_FOR_URL_SHORTNER);
                }
            }
        }
    });
}
 
Example #3
Source File: GooglePlayServicesAvailabilityIOException.java    From google-api-java-client with Apache License 2.0 4 votes vote down vote up
/**
 * @since 1.21.0
 */
public GooglePlayServicesAvailabilityIOException(
    GooglePlayServicesAvailabilityException wrapped) {
  super(wrapped);
}
 
Example #4
Source File: GooglePlayServicesAvailabilityIOException.java    From google-api-java-client with Apache License 2.0 4 votes vote down vote up
@Override
public GooglePlayServicesAvailabilityException getCause() {
  return (GooglePlayServicesAvailabilityException) super.getCause();
}