1

I want to make an application that gets the phone location each 30 min and save it to a DB (and transmits to a webserver).

The application should be running in the background for a few hours while the user can be doing other things with his phone (games, calls...)

Can someone please advice what is the best solution for this project? (Service? AlermManager?)

Janusz
  • 187,060
  • 113
  • 301
  • 369
user733284
  • 925
  • 2
  • 11
  • 18
  • Jepp, service is the right way to go, [you will find this thread interesting](http://stackoverflow.com/questions/7909805/determining-if-gps-is-failing-to-get-a-lock) – Reno Nov 04 '11 at 07:34

2 Answers2

2

In my case Android - Service is the best solution for me.

For service Example - ServicesDemo - Using Android Services

Define and consume your own service .

EDIT: look at this SO question Running a service to get location details

Community
  • 1
  • 1
user370305
  • 108,599
  • 23
  • 164
  • 151
1

A good way to this is by registering a pending Intent instead of an location listener.

This makes it possible that your App is not running while it is waiting for a new location. The pending Intent should point to an intent service, in that way you don't need to think about working in the background after you received a new location.

If you don't need more location updates you only have to unregister the intent.

Janusz
  • 187,060
  • 113
  • 301
  • 369