Android Alarm Manager setExactAndAllowWhileIdle() not working in Android 7.0 Nougat in Doze mode

后端 未结 3 1567
滥情空心
滥情空心 2020-12-25 14:24

I am trying to make an alarm fire in my app every 30 minutes using Alarm Manager\'s setExactAndAllowWhileIdle but it is not working!

I test the function

相关标签:
3条回答
  • 2020-12-25 14:53

    You might get accurate alarms, but in Doze mode

    The system ignores wake locks.

    So it seems as though AlarmManager.setAlarmClock is the only acceptable solution if you really need to trigger every 30 minutes. This will probably negate all doze mode energy savings...

    BTW: it seems like you can see alarms with adb shell dumpsys alarm.


    Possibility: use Firebase JobDispatcher

    The Firebase JobDispatcher is a library for scheduling background jobs in your Android app. It provides a JobScheduler-compatible API that works on all recent versions of Android (API level 14+) that have Google Play services installed.

    0 讨论(0)
  • 2020-12-25 14:56

    I got the same problem as you, and searches a long time for an solution. But I doesn't find a general solution.

    A solution for Samsung devices is available: Android AlarmManager not working on some devices when the app is closed

    The first answer works not, but the second one :)

    0 讨论(0)
  • 2020-12-25 15:01

    Have you tried add your app to the battery optimisation whitelist? As some news pointed out (link), Huawei has some special battery management.

    0 讨论(0)
提交回复
热议问题