JobScheduler is not working in Xiaomi when app is not in background and auto-start option is disabled

筅森魡賤 提交于 2020-02-24 14:28:07

问题


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 ?


回答1:


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?




回答2:


Use WorkManager from now on. It will handle every thing automatically depending on the Android version



来源:https://stackoverflow.com/questions/52927465/jobscheduler-is-not-working-in-xiaomi-when-app-is-not-in-background-and-auto-sta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!