JobScheduler Is Not Working In Xiaomi When App Is Not In Background And Auto-start Option Is Disabled

I want to run a task in my app everyday, I am using JobScheduler for it and works fine in stock OS, but when I try to run it in phones which has custom ROM (Xiaomi) it doesn't work unless I explicitly enable auto-start option for the app in security. Is there any solution for this, how are other apps handling this scenario ?



This is a known issue with some Android OEM that heavily modify this part of Android for battery optimization.

Aside having you application added to the whitelist, you can really only report the issue:

  • to the OEM (Xiaomi in this case) to avoid this kind of breaking changes.
  • to Google, to add a test in the CTS and avoid these behaviours by the OEMs.

Using WorkManager is not going to solve this problem because WM still uses JobScheduler API when it's available.
From WorkManager's issue tracker: are the Chinese manufacturers (Huawei, Oppo, Xiaomi...) supported?