android - Google Nexus 4 未调用警报管理器

标签 android alarmmanager android-alarms repeatingalarm

我开发了一款 Android 应用。我需要为某些操作设置警报。

问题是警报接收器在所有其他设备上都能正常工作,但在 Google Nexus 4 上它有时会被调用但有时不会! :-(

当我设置闹钟时,它会打印如下日志,比当前时间晚 5 分钟。

Alarm set for : Fri Jun 20 06:07:00 GMT+00:00 2014

但是当时间到了时,它有时会被调用,有时却不会! :-(

我已将日志放入接收器,它有时会打印出来。

求助! 谢谢!

最佳答案

自 API19 以来,警报管理器有点随机:

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.

http://developer.android.com/reference/android/app/AlarmManager.html

关于android - Google Nexus 4 未调用警报管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24321194/

相关文章:

android - RecyclerView 删除/添加重叠分隔线的动画

java - Android: 二维 ArrayList 帮助

java - java中如何拆分字符串

android - 如何设置警报和通知?

android - 即使在重新启动后如何创建持久警报

java - 更改 Android Tabview 中的标签文本

javascript - 在 Android Xamarin CrossWalk Webview 中从 Javascript 调用 C# 函数

android - 对于积极重复的警报,哪个更好 Alarm 或 Service with Timer 任务?

android - 手机重启后AlarmManager报警不触发

android - 如何在我的应用程序中实现系统闹钟?