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开发者_JAVA百科(LocationManager.GPS_PROVIDER,0,3,this);
, would it be enough to just remove this
once as follows
manager.removeUpdates(this);
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.
精彩评论