setAndAllowWhileIdle和setExactAndAllowWhileIdle之间的区别 [英] Difference between setAndAllowWhileIdle and setExactAndAllowWhileIdle
问题描述
AlarmManager.setAndAllowWhileIdle()
和AlarmManager.setExactAndAllowWhileIdle()
有什么区别?这些都如何影响Android 6.0(棉花糖)API中引入的打ze模式?
What is difference between AlarmManager.setAndAllowWhileIdle()
and AlarmManager.setExactAndAllowWhileIdle()
? How does these both affect Doze mode introduced in Android 6.0 (Marshmallow) API?
推荐答案
请参阅AlarmManager
的文档:
注意:从API 19(KITKAT)开始,警报传递是不准确的:操作系统将转移警报,以最大程度地减少唤醒时间和电池消耗.有一些新的API支持需要严格交付保证的应用程序.请参见setWindow(int,long,long,PendingIntent)和setExact(int,long,PendingIntent). targetSdkVersion早于API 19的应用程序将继续看到以前的行为,在该行为中,所有警报均在请求时准确地传递.
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"(set
和setExact
)的对应方法.因此,其中一个将在准确的时间发出警报,而另一个将不准确.
Indeed, both the methods you mentioned specify that they behave like their counterparts without the "AndAllowWhileIdle" (set
and setExact
). So one of them will deliver the alarm at the exact time and the other will not be exact.
这篇关于setAndAllowWhileIdle和setExactAndAllowWhileIdle之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!