How to set an exact repeating alarm on API 19 (kit

2019-01-26 07:59发布

Starting from API 19, setRepeating() works the same way as setInexactRepeating(). What's the new way of setting an exact repeating alarm?

I.e. What's the API 19 version of the good old setRepeating()? Could you please provide an example for setting an alarm at 7:30 every morning (repeating daily) on KitKat?

1条回答
【Aperson】
2楼-- · 2019-01-26 08:56

It doesn't exist, unfortunately. From the documentation:

Note: as of API 19, all repeating alarms are inexact. If your application needs precise delivery times then it must use one-time exact alarms, rescheduling each time as described above. Legacy applications whose targetSdkVersion is earlier than API 19 will continue to have all of their alarms, including repeating alarms, treated as exact.

In short, if you need exact repeating alams, you can create an alarm with setExact(), but you'll need to handle the "repeating" part manually.

查看更多
登录 后发表回答