Skip to content

Instantly share code, notes, and snippets.

@jaredjenkins
Created January 22, 2014 07:43
Show Gist options
  • Save jaredjenkins/8554909 to your computer and use it in GitHub Desktop.
Save jaredjenkins/8554909 to your computer and use it in GitHub Desktop.
Debugging GooglePlayServices availability
//copy this into an activity
public boolean isGooglePlaySdkAvailable(){
try{
Class.forName("com.google.android.gms.common.GooglePlayServicesUtil");
return true;
} catch(ClassNotFoundException exception){
logger.log(LogLevel.WARNING, "Google Play Services are not available on this device.");
}
return false;
}
public int getGooglePlayServiceStatus(Context context){
return GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
}
//then call within your onCreate method
//it might help to set some break points
if(!isGooglePlaySdkAvailable()){
Log.i("Tango", "Google Play Services class cannot be located. Looks like the JAR is missing.");
} else {
int status = getGooglePlayServiceStatus(this);
//check the value of status
Log.i("Tango", String.format("Google Play Services status code %d", status));
if(status == ConnectionResult.SUCCESS){
Log.i("Tango", "Google Play Services up-to-date");
} else {
Log.i("Tango", "Google Play Services error received.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment