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

后端 未结 3 1569
滥情空心
滥情空心 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.

提交回复
热议问题