title: onPause to stop LocationManager
body: <p>I think I’m doing this right?</p>
  
  <p>I have this code which starts looking for my GPS location via a MyLocationListener method not displayed here, that works but I want to stop the locationManager onPause, I think or whenever this activity is not current, but I can’t get the removeUpdates code to resolve.</p>
  
  <pre><code>locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);        
  locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES, MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, new MyLocationListener());
  </code></pre>
  
  <p>and then,</p>
  
  <pre><code>@Override 
  public void onPause()
  {
      super.onPause();
      locationManager.removeUpdates(MyLocationListener);
  }
  </code></pre>
  
  <p>“MyLocationListener” wont resolve, I’ve also tried “this” and,</p>
  
  <pre><code>locationManager.removeUpdates((LocationListener) this);
  </code></pre>
  
  <p>Which resolves but gives me a “Cannot Pause” error at runtime.</p>