2

When developing a location-aware Android application using a LocationListener, is it obligatory to call LocationManager.removeUpdates() before the application finishes?

Or more generally, is it obligatory to call LocationManager.removeUpdates() before the Looper passed in LocationManager.requestLocationUpdates() quits?

Does the LocationManager automatically find out that the Looper is no longer alive and location updates are no longer necessary? If yes, how? If not, will it keep blindly updating (and draining the battery) forever?

bryn
  • 51
  • 1

1 Answers1

0

When your app gets cleaned from the stack it will remove the location updates as well. If the user only removes you from the foreground you will keep getting updates until the system clean your app. It's a good practice to remove updates when you no longer needs them and if you'll try to register your location again (lets say in another lunch of your app) it will throw an exception saying that you didn't use unRegister.

Ohad Zadok
  • 3,452
  • 1
  • 22
  • 26