Created
January 22, 2014 07:43
-
-
Save jaredjenkins/8554909 to your computer and use it in GitHub Desktop.
Debugging GooglePlayServices availability
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
//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