Difference between 'setExact' and 'setAlarmClock'

后端 未结 2 748
情话喂你
情话喂你 2020-12-06 12:03

In my application which was supposed to trigger an alarm at a specified time, alarm whose purpose was to inform the user via a Notification, I despaired at obta

2条回答
  •  爱一瞬间的悲伤
    2020-12-06 12:33

    Doze mode, introduced in Android 6.0 (API level 23), adds further restrictions to those outlined above: (TL;DR: only setAlarmClock triggers in doze mode, and adds a system icon)

    Doze restrictions

    The following restrictions apply to your apps while in Doze: [...]

    • The system ignores wake locks.
    • Standard AlarmManager alarms (including setExact() and setWindow()) are deferred to the next maintenance window.
      • If you need to set alarms that fire while in Doze, use setAndAllowWhileIdle() or setExactAndAllowWhileIdle().
      • Alarms set with setAlarmClock() continue to fire normally — the system exits Doze shortly before those alarms fire. [...]

    The devices enter the low-power doze-state with periodic wake-ups to perform the other alarms etc.

提交回复
热议问题