且构网

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

Android警报管理器setExactAndAllowWhileIdle()在打ze模式下无法在Android 7.0牛轧糖中使用

更新时间:2023-10-29 19:49:34

您可能会收到准确的警报,但

You might get accurate alarms, but in Doze mode

系统忽略唤醒锁.

The system ignores wake locks.

因此,好像 AlarmManager.setAlarmClock 是唯一可接受的解决方案.这可能会抵消所有打do模式的节能效果.

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