Difference between setAndAllowWhileIdle and setExactAndAllowWhileIdle

江枫思渺然 提交于 2019-12-10 20:32:37

问题


What is difference between AlarmManager.setAndAllowWhileIdle() and AlarmManager.setExactAndAllowWhileIdle()? How does these both affect Doze mode introduced in Android 6.0 (Marshmallow) API?


回答1:


Refer to the documentation of 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.

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.



来源:https://stackoverflow.com/questions/35666127/difference-between-setandallowwhileidle-and-setexactandallowwhileidle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!