Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android how to stop gps

Tags:

android

gps

After launching listener by the following code is working fine.

LocationManager locationManager =(LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
                    LocationManager.GPS_PROVIDER, WLConstants.DELAY_HOUR, gpsl
                            .getMinDistance(), gpsl);

After some time i stop the listener by the following code

locationManager.removeUpdates(this);

but problem is it still searching my gps any solution ??? how to stop gps ?

like image 802
d-man Avatar asked Jan 06 '10 12:01

d-man


2 Answers

You need to pass the same object implementing LocationListener that you requested location updates for to the locationManager.removeUpdates() method.

So in unless this and gpsl are one and the same, you should call:

locationManager.removeUpdates(gpsl);
like image 99
Jeff Gilfelt Avatar answered Sep 23 '22 00:09

Jeff Gilfelt


If you are using maps, you have to do:

locationManager.removeUpdates(locationListener);

mMap.setMylocationEnabled(false);
like image 24
Claw Hammer Avatar answered Sep 23 '22 00:09

Claw Hammer