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 location.
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
LocationListenersany time you leave anActivity.You’ll know if you’ve left
LocationListenersopen 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
LocationListenerfor your application, you could put this into aService.