Last active
May 5, 2016 09:25
-
-
Save manishpathak99/9208814d1c0ee6840343b8023204041d to your computer and use it in GitHub Desktop.
Check Google Play Service Lolipop
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
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