且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android 警报管理器 setExactAndAllowWhileIdle() 在处于打盹模式的 Android 7.0 Nougat 中不起作用

更新时间:2023-10-29 19:58:28

你可能会得到准确的警报,但 处于打盹模式

You might get accurate alarms, but in Doze mode

系统忽略唤醒锁.

所以看起来好像 AlarmManager.setAlarmClock 是唯一可以接受的解决方案,如果您确实需要每 30 分钟触发一次.这可能会抵消所有打盹模式的节能...

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...

顺便说一句:似乎您可以使用 adb shell dumpsys alarm 看到警报.

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

可能性:使用 Firebase JobDispatcher

Firebase JobDispatcher 是一个用于在您的 Android 应用中安排后台作业的库.它提供了一个兼容 JobScheduler 的 API,适用于安装了 Google Play 服务的所有最新版本的 Android(API 级别 14+).

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.