Created
August 15, 2018 06:40
-
-
Save SteveKamau72/69d1e5d4e91762e9e146e75d115a00ab to your computer and use it in GitHub Desktop.
Android: Check whether Google Play Services are installed and current
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check whether Google Play Services are available. | |
* | |
* If not, then display dialog allowing user to update Google Play Services | |
* | |
* @return true if available, or false if not | |
*/ | |
private boolean checkGooglePlayServicesAvailable() | |
{ | |
final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); | |
if (status == ConnectionResult.SUCCESS) | |
{ | |
return true; | |
} | |
Log.e(LOGTAG, "Google Play Services not available: " + GooglePlayServicesUtil.getErrorString(status)); | |
if (GooglePlayServicesUtil.isUserRecoverableError(status)) | |
{ | |
final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(status, this, 1); | |
if (errorDialog != null) | |
{ | |
errorDialog.show(); | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment