title: Google Maps onResume
body: <p>i'm using google maps in my android app. Everything is fine but when i have no GPS service enabled i show a snackbar message to enable. When i enable GPS and turn back in my Fragment der map dosen't return to my location automaticly only when i press the location button.</p>
  
  <p>I tried to solve the problem by using a thread in my update method but nothing. changed. Sometimes it works but sometimes isn't good enough.</p>
  
  <p>my onCreate:</p>
  
  <pre><code> public  void init(){
      gps = new GPSTracker();
      gps.init(mActivity,mActivity);
      if (!gps.canGetLocation()) {
          gps.showSettingsAlert(mActivity,rootView);
      }else {
          initMap();
      }
  </code></pre>
  
  <p>my initMap</p>
  
  <pre><code> private void initMap(){
      try {
          MapsInitializer.initialize(mActivity.getApplicationContext());
      } catch (Exception e) {
          e.printStackTrace();
      }
      mMapView.getMapAsync(new OnMapReadyCallback() {
          @Override
          public void onMapReady(GoogleMap mMap) {
              googleMap = mMap;
              if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
                  googleMap.setMyLocationEnabled(true);
              }
              moveSearchCircle(new LatLng(gps.getLatitude(), gps.getLongitude()));
              updateMapPosition();
              googleMap.setIndoorEnabled(true);
              addMarker();
          }
      });
  }
  </code></pre>
  
  <p>updateMapPosition</p>
  
  <pre><code> private void updateMapPosition(){
          googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(gps.getLatitude(), gps.getLongitude()), 15));
     }
  </code></pre>
  
  <p>onResume</p>
  
  <pre><code> @Override
  public void onResume() {
      super.onResume();
      init();
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/TT6RP.png" rel="nofollow"><img src="https://i.stack.imgur.com/TT6RP.png" alt="enter image description here"></a></p>