title: How can I show current location on a Google Map on Android Marshmallow?
body: <p>I want google maps to show the location of the user. I tried this code, but it did not work on Android 6.</p>
  
  <pre><code>private GoogleMap map;
  LocationManager lm;
  LocationListener ll;
  Location l;
  
  LatLng pos;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.start_layout);
  
      lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
      ll = new LocationListener() {
          @Override
          public void onLocationChanged(Location location) {
              l = (Location) location;
          }
  
          @Override
          public void onStatusChanged(String provider, int status, Bundle extras) {}
  
          @Override
          public void onProviderEnabled(String provider) {}
  
          @Override
          public void onProviderDisabled(String provider) {}
      };
  
      SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
              .findFragmentById(R.id.nMap);
      mapFragment.getMapAsync(this);
  }
  
  @Override
  public void onMapReady(GoogleMap googleMap) {
      map = googleMap;
  
      if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
          lm.requestLocationUpdates(lm.NETWORK_PROVIDER, 0, 0, ll);
      }
  
      pos = new LatLng(l.getLatitude(), l.getLongitude());
  
      // Add a marker in Sydney and move the camera
      map.setMyLocationEnabled(true);
      map.addMarker(new MarkerOptions().position(pos).title("Marker in Sydney"));
      map.moveCamera(CameraUpdateFactory.newLatLng(pos));
  }
  </code></pre>
  
  <p>Here are the permissions I've set:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>