Skip to content

Instantly share code, notes, and snippets.

@manishpathak99
Last active May 5, 2016 09:25
Show Gist options
  • Save manishpathak99/9208814d1c0ee6840343b8023204041d to your computer and use it in GitHub Desktop.
Save manishpathak99/9208814d1c0ee6840343b8023204041d to your computer and use it in GitHub Desktop.
Check Google Play Service Lolipop
public class GooglePlayServiceUtil {
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
/**
* Use this method in onCreate method of activity
*
* 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() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment