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?
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;
}
}
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);
}
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.