Note that there are some explanatory texts on larger screens.

plurals
  1. POThe GPS updates won't turn off after closing application
    text
    copied!<p>I have created an application that has a 'geolocation' feature responsible for spotting a user on the Google map like many other applicatons. I used "LocationManager.NETWORK_PROVIDER" to locate the user and at the same time I instantiate and start "MyLocationOverlay" (in the <code>onLocationChanged()</code> method) to get the location. Because of the second one, the GPS turns on (blinking on the top) which is OK.</p> <p>The problem is, after the application is closed (back button or through task manager), the GPS feature is still hanging there, trying to get the updates. </p> <p>How to turn it off after the user leaves the activity? I tried suggestions from here and other forums like putting <code>locationManager.removeUpdates(this);</code> and <code>locationManager.removeUpdates(mMyLocationOverlay);</code> within the methods <code>onPause()</code>, <code>onStop()</code>, <code>onDestroy()</code>. The method <code>OnPause</code> looks like this:</p> <pre><code>@Override protected void onPause() { super.onPause(); locationManager.removeUpdates(this); locationManager.removeUpdates(mMyLocationOverlay); } </code></pre> <p>('this' references my class that implements LocationListener)</p> <p>Please, can someone help me to turn off GPS updates after leaving the activity (it's a class that extends MapActivity) but not turn off the GPS feature on the phone itself?</p> <p>Interesting thing is that when I remove the part with MyLocationOverlay, GPS will not start of course and therefore no problem. So I'm pretty sure that <code>mMyLocationOverlay</code> is the listener that "won't stop" and producing a problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload