2

有沒有辦法確保最新的谷歌服務安裝在設備上?如果不是不在應用程序上顯示地圖並且沒有應用程序崩潰?Android谷歌地圖v2

回答

1

希望它可以幫助

public boolean isGoogleMapsInstalled() 
{ 
    try 
    { 
     ApplicationInfo info = getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0); 
     return true; 
    } 
    catch(PackageManager.NameNotFoundException e) 
    { 
     return false; 
    } 
} 
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); 
} 
1

嘗試這種方式

private boolean checkPlayServices() { 
     int resultCode = GooglePlayServicesUtil 
       .isGooglePlayServicesAvailable(this); 
     if (resultCode != ConnectionResult.SUCCESS) { 
      return false; 
     }else{ 
        GooglePlayServicesUtil.getErrorDialog(resultCode, this, 
        9000).show(); 
      } 
     return true; 
    }