Ensure foreground service is not cached after 30 minutes

193 Views Asked by At

Acording to the documentation here https://developer.android.com/guide/components/activities/process-lifecycle

Services that have been running for a long time (such as 30 minutes or more) may be demoted in importance to allow their process to drop to the cached list

I have an app which is tracking, for logging purposes, user position. I am using a foreground service to keep app alive, even when not visible, and that works, but only being able to do that for 30 minutes is too little.

In my testing (mainly Huawei phone) I have to go to battery settings and explicitly allow the app to keep running in backgrounda, ang that works, but that is not really a viable solution.

How are you supposed to handle this?

0

There are 0 best solutions below