Background Service being killed on android

Asked

Viewed 9 times

-1

We created a GPS monitoring application, every 30 seconds or so the application updates the user’s position on the server. With the recent changes of Android 8 and following, we saw that the issue of battery use was greatly enhanced by android, which causes some devices/ manufacturers, kill services that run in the background after a while. And basically that’s what’s happening to us, especially on Xiaomi devices.

The question is, is it possible to circumvent this scenario? Recreate a service whenever it is killed by android?

1 answer

0

I’m totally out of Android these days, but services have always been volatile things, which should not run in a prolonged way because they have always been subject to being killed by the OS.

In this case the right then is not leave the service running and dormant most of the time, but schedule (Schedule) a task (I can’t remember the name of the component that does this on Android) to repeat every 30 seconds a broadcast receiver that calls a short-term service that reads the GPS and transmits the position to the server (with possible local buffering if necessary in case of missing time connectivity).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.