Difference between setAndAllowWhileIdle and setExactAndAllowWhileIdle
Asked Answered
T

1

6

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

Thomas answered 27/2, 2016 at 5:33 Comment(0)
S
3

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.

Steppe answered 27/2, 2016 at 5:37 Comment(2)
What is effect of Marshmallow doze on these APIs?Thomas
@Malwinder presumably the "AndAllowWhileIdle" ones will still be delivered if the device is dozing.Steppe

© 2022 - 2024 — McMap. All rights reserved.