Android AlarmManager setExact() is not exact

后端 未结 6 811
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 04:30

I need to plan sheduled task every 10 minutes.

As in Lollipop and higher version setRepeating() is inexact, I use setExact() and (on alarm

6条回答
  •  独厮守ぢ
    2020-12-01 05:23

    From android documentation of AlarmManager

    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.

    Also while using setExact() :

    The alarm will be delivered as nearly as possible to the requested trigger time.

    So its still not guaranteed that setExact will be Exact.

提交回复
热议问题