I'm designing an application where application in server side need to be continuously aware of user location. I'm thinking to create an Android service that run in the background and continuously query user location and send the result to an application in the backend server. However, I wonder if this is the best approach in terms of battery saving. For example, in iOS, there is something called "Significant-Change" to serve such purpose, does Android have similar thing.
Asked
Active
Viewed 9,017 times
12
-
on iOS, this "significant-change" is not what you might think. a significant change may occur while the device is switching between cell towers, and not actually occurring after a change every `x` in distance. When using this `significant-change` feature, you will receive location updates not often enough for practical use(unless you want to track only a few locations) – james Nov 30 '11 at 22:25
1 Answers
15
I suggest to create a background Service which just uses the NETWORK_PROVIDER and the PASSIVE_PROVIDER. You can use the minTime and the minDistance parameter to avoid draining the battery. Documentation
And Reto wrote a great post about obtaining users location http://android-developers.blogspot.com/2011/06/deep-dive-into-location.html
Regarding your comment you have to start your service sticky: Documentation

Dominic
- 3,353
- 36
- 47
-
Thanks ... in this case, how could I make sure that the system will not kill my service, or at least, how could I know if the service is killed so that I could run it again? – user836026 Dec 01 '11 at 08:15
-
@DominicBartl It would be interesting what you think about the option proposed here: http://stackoverflow.com/questions/18260531/how-to-continuously-track-the-location-of-an-android-mobile-phone – Glory to Russia Aug 20 '13 at 06:57