Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a LocationListener from LocationManager that is added twice in android?

If I add this as a LocationListener twice as follows

manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0,3,this);
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,3,this);

, would it be enough to just remove this once as follows

manager.removeUpdates(this);
like image 614
Gallal Avatar asked Dec 19 '10 22:12

Gallal


1 Answers

Yes, removing manager.removeUpdates(this); is enough. As the documentation says:

Removes any current registration for location updates of the current activity with the given LocationListener. Following this call, updates will no longer occur for this listener.

like image 66
keyboardsurfer Avatar answered Nov 11 '22 17:11

keyboardsurfer