2

有没有办法确保设备上安装了最新的谷歌服务?如果没有在应用程序上显示地图并且没有应用程序崩溃?

4

3 回答 3

1

希望能帮助到你

public boolean isGoogleMapsInstalled()
{
    try
    {
        ApplicationInfo info = getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0 );
        return true;
    } 
    catch(PackageManager.NameNotFoundException e)
    {
        return false;
    }
}
于 2013-09-25T07:01:56.890 回答
1

您可以致电:

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);
}
于 2013-09-25T07:05:49.947 回答
1

试试这个方法

private boolean checkPlayServices() {
        int resultCode = GooglePlayServicesUtil
                .isGooglePlayServicesAvailable(this);
        if (resultCode != ConnectionResult.SUCCESS) {
            return false;
        }else{
                   GooglePlayServicesUtil.getErrorDialog(resultCode, this,
                    9000).show();
            }
        return true;
    }
于 2013-09-25T07:08:02.180 回答