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
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.
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 :)
Have you tried add your app to the battery optimisation whitelist? As some news pointed out (link), Huawei has some special battery management.