Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long-running background task that doesn't get killed

I'm trying to fetch the user's location every 15 minutes, whether the app is in the foreground, background, or killed.

I've implemented a WorkManager, which works well on my Pixel in all 3 cases above. But I've just read that many phone manufacturers, including Samsung, often kill Workers either through battery optimization or otherwise, despite it often violating Google's policy:

https://stackoverflow.com/a/52605503/14968122

Do I have any options here to address my Workers being killed by these manufacturers? Are there workarounds or other solutions/implementations that I should be aware of to prevent these manufacturers from stopping my Workers?

Thanks you

like image 509
user1695123 Avatar asked Apr 24 '26 15:04

user1695123


1 Answers

Check here:

https://dontkillmyapp.com/

Ask to be exempted from Battery optimization:

https://developer.android.com/training/monitoring-device-state/doze-standby#support_for_other_use_cases

But no matter what - this is Android. There is no bulletproof solution.

like image 150
Yavor Mitev Avatar answered Apr 27 '26 04:04

Yavor Mitev