title: Maps API only loads with location setting GPS
body: <p>I use the Google Maps API in my Android app and locate the user with 
  <code>LocationManager</code> and <code>getLongitude()</code>, <code>getLatitude()</code>.
  But now there have to be strange settings on the mobile phone to get a map. The location setting has to be changed to only use GPS, and even then it's not working all the time, sometimes the map is not loaded. If not loaded the app shuts down at the point the first marker is set because of <code>NullPointerException</code>.</p>
  
  <p>Why is this and how can I prevent it?
  I already tried with <code>getMapAsync</code> but it didn't help.</p>
  
  <pre><code>GoogleMap googleMap;
  LocationManager locationManager;
  String provider;
  Criteria criteria;
  Location myLocation;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_map);
  
     try {
          if(googleMap == null) {
              googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
          }
          googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
          googleMap.setMyLocationEnabled(true);
          googleMap.setTrafficEnabled(true);
          googleMap.setIndoorEnabled(true);
          googleMap.setBuildingsEnabled(true);
          googleMap.getUiSettings().setZoomControlsEnabled(true);
  
          locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
          criteria = new Criteria();
          provider = locationManager.getBestProvider(criteria, true);
          myLocation = locationManager.getLastKnownLocation(provider);
          double latitude = myLocation.getLatitude();
          double longitude = myLocation.getLongitude();
          LatLng latLng = new LatLng(latitude, longitude);
          googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
          googleMap.animateCamera(CameraUpdateFactory.zoomTo(14));
          iconDone = R.drawable.markerdone;
          icon = R.drawable.marker;
      }
      catch(Exception e) {
          e.printStackTrace();
      }
  
      Marker marker1 = googleMap.addMarker(new MarkerOptions()
              .position(new LatLng(49.793012, 9.926201))
              .title(getString(R.string.Title1))
              .snippet("")
              .icon(BitmapDescriptorFactory.fromResource(icon)));
  </code></pre>