Search code examples
androidgeolocationgpslocationlistener

android: LocationListener running permanently


I have an app which will start sending location data to a remote server, when I press a button. I am using LocationListener since I want to send the location points if a certain distance or time threshold is reached.

I want the LocationListener to send data to the server as long as the phone is on and the button is not pressed back to shut it down.

How can I do that?

How can I have the LocationListener to run continuously as long as the phone is on - even if I am not running the app which activated the location listener?


Solution

  • You have to run this in a service. Are you sure you want to do this though? This will drain the battery fairly quickly.