开发者

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

开发者 https://www.devze.com 2023-01-31 21:38 出处:网络
If I add this as a LocationListener twice as follows manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0,3,this);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消