android - 为什么 Alarm Manager 仅在 30 分钟内更新?

标签 android alarmmanager

我想制作一个每秒更新一次(更多电池消耗)或每分钟(更少电池消耗)的小部件。

我按照 this thread 中的方式进行了跟踪

,但仅每 30 分钟运行一次。

我配置的是,一旦 onUpdate 运行,它会在 1 分钟内更新,并且 onReceived 每 30 分钟运行一次。

谁能告诉我我做错了什么?

最佳答案

根据我的经验,AlarmManager 在间隔小于 1 分钟时不能正常工作(或根本不能正常工作)。此外:

Note: The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running. For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to use Handler.

另外:

Note: Beginning with API 19 (KITKAT) alarm delivery is inexact: the OS will shift alarms in order to minimize wakeups and battery use. There are new APIs to support applications which need strict delivery guarantees; see setWindow(int, long, long, PendingIntent) and setExact(int, long, PendingIntent). Applications whose targetSdkVersion is earlier than API 19 will continue to see the previous behavior in which all alarms are delivered exactly when requested.

关于android - 为什么 Alarm Manager 仅在 30 分钟内更新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20681667/

相关文章:

java - 如何安排我的 Android 应用程序每小时做一些事情

android - ProgressBar 不以 fragment 为中心

安卓应用统计 : What does 'Others' mean under 'Total Installs by User' metric?

android - 处理产品口味时,main/AndroidManifest.xml 中的包名称应该是什么?

java - AlarmManager 膨胀布局

java - 检查 AlarmManager 任务是否正在进行

android - 在 android 上使用给定时间使用 AlarmManager 安排闹钟

java - 当我将语言更改为波斯语时,从右向左填写按钮

android - 如何通过 Android Keystore 使用 key 哈希消息身份验证代码 (HMAC)

android - 小米、魅族、华为的闹钟管理器