0

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?

Asciiom
  • 9,867
  • 7
  • 38
  • 57
user522559
  • 239
  • 5
  • 13

1 Answers1

1

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

Falmarri
  • 47,727
  • 41
  • 151
  • 191
  • Thanks for the answer. Well that's why I keep a button for activating/deactivating the service. I want to user to do something else while he needs to update the server with his location data. – user522559 Dec 26 '10 at 01:38
  • refer this http://stackoverflow.com/questions/4416141/a-background-sensor-data-collector-in-android/4416626#4416626 – mad Dec 26 '10 at 11:31