Mapy Google Android API V2 sprawdzają, czy GoogleMaps są zainstalowane na urządzeniu

Podczas korzystania z Google Maps Android API V2 obserwujęDokumentacja konfiguracji usług Google Play aby sprawdzić, czy usługi Google Play są zainstalowane, używając następującego kodu w mojej głównej działalności:

@Override
public void onResume()
{
      checkGooglePlayServicesAvailability();

      super.onResume();
}

public void checkGooglePlayServicesAvailability()
  {
      int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
      if(resultCode != ConnectionResult.SUCCESS)
      {
          Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 69);
          dialog.setCancelable(false);
          dialog.setOnDismissListener(getOnDismissListener());
          dialog.show();
      }

      Log.d("GooglePlayServicesUtil Check", "Result is: " + resultCode);
  }

To działa dobrze. Zauważyłem jednak, że niektóre starsze telefony z systemem Android, na których się znajdowałem (głównie działające w wersji 2.2), nie posiadały zarówno GooglePlayServices, jak i samej aplikacji Google Maps.

LogCat zgłosi ten błąd: Google Maps Android API: brakuje aplikacji Mapy Google.

Pytanie - w jaki sposób mogę wykonać podobne sprawdzenie, jak w przypadku dostępności Map Google na urządzeniu? Po drugie, jeśli użytkownik ma już zainstalowane Mapy Google, myślę, że sprawdzenie będzie musiało upewnić się, że ich zainstalowana wersja jest zgodna z V2 Android Maps API.

Aktualizacja Oto moja metoda setupMapIfNeeded (), która jest wywoływana na końcu onCreate (). W tym miejscu chciałbym określić, czy Google Maps jest zainstalowany i powiadomić użytkownika, zobacz blok inny:

private void setUpMapIfNeeded() 
{
    // Do a null check to confirm that we have not already instantiated the map.
    if (mMap == null) 
    {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.basicMap)).getMap();

        if (mMap != null) 
        {
            mMap.setLocationSource(this);

            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(44.9800, -93.2636), 10.0f));
            setUpMap();
        }
        else
        {
            //THIS CODE NEVER EXECUTES - mMap is non-null even when Google Maps are not installed
            MapConstants.showOkDialogWithText(this, R.string.installGoogleMaps);
        }
    }
}

questionAnswers(3)

yourAnswerToTheQuestion