title: Google Maps Android API V2 check if GoogleMaps are installed on device
body: <p>When using Google Maps Android API V2 I'm following the <a href="https://developer.android.com/google/play-services/setup.html" rel="noreferrer">Google Play Services setup documentation</a> to make a check to ensure that Google Play Services are installed, using the following code in my main Activity:</p>
  
  <pre><code>@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);
    }
  </code></pre>
  
  <p>This works fine.  However, I noticed some of the older Android phones I have laying around (mostly running 2.2) were missing both GooglePlayServices as well as the Google Maps app itself.</p>
  
  <p>LogCat will report this error:
  Google Maps Android API: Google Maps application is missing.</p>
  
  <p><strong>Question</strong> - how can I perform a similar check to the one above for the availability of Google Maps on a device?  Secondly, if the user already has Google Maps installed I think the check will need to make sure their installed version is compatible with V2 of the Android Maps API.</p>
  
  <p><strong>Update</strong>
  Here is my setupMapIfNeeded() method which is called at the end of onCreate().  This is where I think I'd want to determine if Google Maps is installed and alert the user, see the else block:</p>
  
  <pre><code>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);
          }
      }
  }
  </code></pre>