android - setAndAllowWhileIdle 和 setExactAndAllowWhileIdle 的区别

标签 android android-6.0-marshmallow android-alarms android-doze-and-standby

AlarmManager.setAndAllowWhileIdle()AlarmManager.setExactAndAllowWhileIdle() 有什么区别?这两者如何影响 Android 6.0 (Marshmallow) API 中引入的打盹模式?

最佳答案

引用AlarmManager的文档:

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.

事实上,您提到的两种方法都指定它们的行为与没有“AndAllowWhileIdle”(setsetExact)的对应方法一样。因此,其中一个会在准确的时间发出警报,而另一个则不准确。

关于android - setAndAllowWhileIdle 和 setExactAndAllowWhileIdle 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35666127/

相关文章:

java - JSOUP 和 Android 模拟器 - 无法解析主机

android - 当设备休眠几个小时时警报不会响起(在 Marshmallow 上)

android - 当用户从最近的应用程序列表中删除应用程序时,如何取消警报管理器警报?

android - 在android中使用FFmpegFrameGrabber,FrameRecorder JavaCv创建的视频中没有捕获声音

javascript - 如何创建内容 slider 的箭头(React-Native)?

android - 在 Android 中,您可以从另一个应用程序中删除一个应用程序吗?

java - Android 闹钟正在运行,但秒数为零时却没有闹钟?

android - 如何发送高优先级 GCM?

java - org.apache.http.entity.FileEntity 在 Android 6 (Marshmallow) 中被弃用

Android 6.0 权限.GET_ACCOUNTS