开发者

LocationListener is being called multiple times

I am working on an Location Based Application. In this application I am using LocationListener class to update the location when the Location is changed. In each Activity i have different LocationListener to update location and do some specific work on updated loc开发者_C百科ation.

But my problem is that when I am changing my location through DDMS, the LocationListener is being called of that current Activity as well as all the activities of the whole application where LocationListener has been defined. I don't know whether there should be one LocationListener for the whole application or for each Activity we should have different LocationListener.


You need to ensure that you unregister your LocationListeners any time you leave an Activity.

You'll know if you've left LocationListeners open if you see the GPS icon flashing at in the status bar, even after you've left your application.

If you really need a long-lived LocationListener for your application, you could put this into a Service.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜