Java Code Examples for com.google.android.gms.common.GooglePlayServicesUtil#isUserRecoverableError()
The following examples show how to use
com.google.android.gms.common.GooglePlayServicesUtil#isUserRecoverableError() .
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: MainActivity.java From MobileShoppingAssistant-sample with Apache License 2.0 | 6 votes |
/** * Checks if Google Play Services are installed and if not it initializes * opening the dialog to allow user to install Google Play Services. * @return a boolean indicating if the Google Play Services are available. */ private boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; }
Example 2
Source File: SignInActivity.java From MobileShoppingAssistant-sample with Apache License 2.0 | 6 votes |
/** * Checks if Google Play Services are installed and if not it initializes * opening the dialog to allow user to install Google Play Services. * @return a boolean indicating if the Google Play Services are available. */ private boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, this, MainActivity.PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Log.i(TAG, "This device is not supported."); finish(); } return false; } return true; }
Example 3
Source File: GacFragment.java From easygoogle with Apache License 2.0 | 6 votes |
private void showErrorDialog(ConnectionResult connectionResult) { int errorCode = connectionResult.getErrorCode(); if (GooglePlayServicesUtil.isUserRecoverableError(errorCode)) { // Show the default Google Play services error dialog which may still start an intent // on our behalf if the user can resolve the issue. GooglePlayServicesUtil.getErrorDialog(errorCode, getActivity(), mResolutionCode, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mShouldResolve = false; } }).show(); } else { // No default Google Play Services error, display a message to the user. String errorString = getString(R.string.play_services_error_fmt, errorCode); Toast.makeText(getActivity(), errorString, Toast.LENGTH_SHORT).show(); mShouldResolve = false; } }
Example 4
Source File: GCMPushPlugin.java From GCMPushPlugin with MIT License | 6 votes |
/** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ private boolean checkPlayServices() { final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(cordova.getActivity()); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { GooglePlayServicesUtil.getErrorDialog(resultCode, cordova.getActivity(), 9000).show(); } }); } else { Log.i(TAG, "This device is not supported."); cordova.getActivity().finish(); } return false; } return true; }
Example 5
Source File: MapsActivity.java From vocefiscal-android with Apache License 2.0 | 6 votes |
/** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ private boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { finish(); } return false; } return true; }
Example 6
Source File: GCMUtils.java From buddycloud-android with Apache License 2.0 | 5 votes |
/** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ public static boolean checkPlayServices(final Context context) { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, (Activity)context, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Logger.info(TAG, "This device is not supported (Google Play Services APK)"); } return false; } return true; }
Example 7
Source File: GCMRegistrar.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean checkPlayServices(android.app.Activity self) { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(mContext); if (resultCode != ConnectionResult.SUCCESS) { Log.e(TAG, "This device does not support GCM"); if (GooglePlayServicesUtil.isUserRecoverableError(resultCode) && self != null) { GooglePlayServicesUtil.getErrorDialog(resultCode, self, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Toast.makeText(mContext, "Sorry, you need to have the Google Play services installed :<", Toast.LENGTH_SHORT).show(); } return false; } else { Log.i(TAG, "Pushfish is ready for Take-Off!"); } return true; }
Example 8
Source File: MainActivity.java From effective_android_sample with Apache License 2.0 | 5 votes |
private boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Log.i(TAG, "Playサービスがサポートされていない端末です"); finish(); } return false; } return true; }
Example 9
Source File: TictactoeActivity.java From appengine-endpoints-tictactoe-android with Apache License 2.0 | 5 votes |
/** * Check that Google Play services APK is installed and up to date. */ private boolean checkGooglePlayServicesAvailable() { final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) { showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode); return false; } return true; }
Example 10
Source File: SignInActivity.java From solutions-mobile-shopping-assistant-android-client with Apache License 2.0 | 5 votes |
/** * Checks if Google Play Services are installed and if not it initializes opening the dialog to * allow user to install Google Play Services. */ private boolean checkGooglePlayServicesAvailable() { final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) { showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode); return false; } return true; }
Example 11
Source File: Utils.java From conference-central-android-app with GNU General Public License v2.0 | 5 votes |
/** * Check that Google Play services APK is installed and up to date. */ public static boolean checkGooglePlayServicesAvailable(Activity activity) { final int connectionStatusCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable(activity); if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) { showGooglePlayServicesAvailabilityErrorDialog(activity, connectionStatusCode); return false; } return true; }
Example 12
Source File: PushEventListener.java From OPFPush with Apache License 2.0 | 5 votes |
@Override public void onNoAvailableProvider(@NonNull final Context context, @NonNull final Map<String, UnrecoverablePushError> pushErrors) { OPFLog.logMethod(context, pushErrors); StateController.putNoAvailableProviderValue(context, true); NetworkController.getInstance().unregister(context); //Log errors. if (!pushErrors.isEmpty()) { for (Map.Entry<String, UnrecoverablePushError> pushErrorEntry : pushErrors.entrySet()) { OPFLog.d("Push provider %1$ss is unavailable. Error : %2$s", pushErrorEntry.getKey(), pushErrorEntry.getValue()); } } if (pushErrors.containsKey(GCMConstants.PROVIDER_NAME)) { final UnrecoverablePushError gcmError = pushErrors.get(GCMConstants.PROVIDER_NAME); final Integer errorCode = gcmError.getAvailabilityErrorCode(); if (gcmError.getType() == AVAILABILITY_ERROR && errorCode != null && GooglePlayServicesUtil.isUserRecoverableError(errorCode)) { final Intent intent = new Intent(SHOW_GCM_ERROR_DIALOG_ACTION); intent.putExtra(GCM_ERROR_CODE_EXTRA_KEY, errorCode); context.sendBroadcast(intent); } } }
Example 13
Source File: SignInActivity.java From ribot-app-android with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mShouldFinishOnStop = false; setContentView(R.layout.activity_sign_in); activityComponent().inject(this); ButterKnife.bind(this); mSignInPresenter.attachView(this); setSignInButtonEnabled(false); int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resultCode == ConnectionResult.SUCCESS) { setSignInButtonEnabled(true); } else if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil .getErrorDialog(resultCode, this, REQUEST_CODE_PLAY_SERVICES) .show(); } else { showNoPlayServicesError(); Timber.e("This device doesn't support Play Services"); } String popUpMessage = getIntent().getStringExtra(EXTRA_POPUP_MESSAGE); if (popUpMessage != null) { DialogFactory.createSimpleOkErrorDialog(this, popUpMessage).show(); } }
Example 14
Source File: MainActivity.java From CalendarQuickStart with MIT License | 5 votes |
/** * Check that Google Play services APK is installed and up to date. Will * launch an error dialog for the user to update Google Play Services if * possible. * @return true if Google Play Services is available and up to * date on this device; false otherwise. */ private boolean isGooglePlayServicesAvailable() { final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) { showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode); return false; } else if (connectionStatusCode != ConnectionResult.SUCCESS ) { return false; } return true; }
Example 15
Source File: GCMRegistrar.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean checkPlayServices(android.app.Activity self) { int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(mContext); if (resultCode != ConnectionResult.SUCCESS) { Log.e(TAG, "This device does not support GCM"); if (GooglePlayServicesUtil.isUserRecoverableError(resultCode) && self != null) { GooglePlayServicesUtil.getErrorDialog(resultCode, self, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Toast.makeText(mContext, "Sorry, you need to have the Google Play services installed :<", Toast.LENGTH_SHORT).show(); } return false; } else { Log.i(TAG, "Pushjet is ready for Take-Off!"); } return true; }
Example 16
Source File: FirstrunActivity.java From shortyz with GNU General Public License v3.0 | 5 votes |
private boolean isGooglePlayServicesAvailable() { if(this.playServicesAvailable != null){ return this.playServicesAvailable; } final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) { showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode); return this.playServicesAvailable = Boolean.FALSE; } else if (connectionStatusCode != ConnectionResult.SUCCESS ) { return this.playServicesAvailable = Boolean.FALSE; } return this.playServicesAvailable = Boolean.TRUE; }
Example 17
Source File: FriendlyPingActivity.java From friendlyping with Apache License 2.0 | 5 votes |
private void showErrorDialog(ConnectionResult connectionResult) { final int errorCode = connectionResult.getErrorCode(); if (GooglePlayServicesUtil.isUserRecoverableError(errorCode)) { // Show the default Google Play services error dialog which may still start an // intent on our behalf if the user can resolve the issue. GooglePlayServicesUtil.getErrorDialog(errorCode, FriendlyPingActivity.this, REQUEST_CODE_SIGN_IN, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mShouldResolve = false; // For simplicity reasons we just finish the activity. // In a real world app you should deal with failing properly. Log.i(TAG, "Could not resolve issue with code: " + errorCode); finish(); } }).show(); } else { // No default Google Play Services error, display a Toast Toast.makeText(FriendlyPingActivity.this, getString(R.string.play_services_error_fmt, errorCode), Toast.LENGTH_SHORT) .show(); mShouldResolve = false; // For simplicity reasons we just finish the activity. // In a real world app you should deal with failing properly. Log.i(TAG, "Could not resolve issue with code: " + errorCode); finish(); } }
Example 18
Source File: Notifications.java From zulip-android with Apache License 2.0 | 5 votes |
private boolean checkPlayServices() { int resultCode = GooglePlayServicesUtil .isGooglePlayServicesAvailable(app); if (resultCode != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) { GooglePlayServicesUtil.getErrorDialog(resultCode, activity, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else { Log.i(TAG, "This device is not supported."); } return false; } return true; }
Example 19
Source File: DriverHome.java From UberClone with MIT License | 5 votes |
private boolean checkPlayServices() { int resultCode= GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (resultCode!=ConnectionResult.SUCCESS){ if(GooglePlayServicesUtil.isUserRecoverableError(resultCode)) GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_REQUEST_CODE).show(); else { Message.messageError(this, Errors.NOT_SUPPORT); finish(); } return false; } return true; }