user733284
user733284

Reputation: 935

What is the best solution for collecting location info in the background?

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?)

Upvotes: 1

Views: 198

Answers (2)

Janusz
Janusz

Reputation: 189444

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.

Upvotes: 1

user370305
user370305

Reputation: 109237

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

Upvotes: 2

Related Questions