title: How can I update my location with Google Maps?
body: <p>I know that if I use this, I can get my location, but how can I get it automatically or by clicking a button; How can I update my location?</p>
  
  <pre><code>@Override
  public void onMapReady(GoogleMap googleMap) {
      mMap = googleMap;
  
      mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(this.getLocation(), 16));
      MarkerOptions a = new MarkerOptions().position(this.getLocation());
      m = mMap.addMarker(a);
  }
  
  private LatLng getLocation() {
      LatLng location = null;
      gps = new GPSTracker(MainActivity.this);
          if (gps.canGetLocation()) {
              double latitude = gps.getLatitude();
              double longitude = gps.getLongitude();
              location = new LatLng(latitude, longitude);
          return location;
  
      } else {
          gps.showSettingsAlert();
          location = new LatLng(-23.036602, -13.183594);
          return location;
      }
  }
  </code></pre>
  
  <p>The only way I could do this was by restarting the activity, but I think this is not the best solution.</p>