Reputation: 111
Is there a way to make sure that the latest google services are installed on the device? and if not not show the maps on the application and not have the application crash?
Upvotes: 2
Views: 104
Reputation: 28484
Try this way
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
return false;
}else{
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
9000).show();
}
return true;
}
Upvotes: 1
Reputation: 2075
You can call:
int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable();
if(code == ConnectionResult.SUCCESS) {
// google play services are up to date
} else {
// get dialog to fix issue
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(code, this, REQUEST_GPS_ERROR_DIALOG);
}
Upvotes: 1
Reputation: 438
Hope it helps
public boolean isGoogleMapsInstalled()
{
try
{
ApplicationInfo info = getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0 );
return true;
}
catch(PackageManager.NameNotFoundException e)
{
return false;
}
}
Upvotes: 1