How to set an exact repeating alarm on API 19 (kitkat)?

老子叫甜甜 提交于 2019-12-18 05:48:05

问题


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:


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.



来源:https://stackoverflow.com/questions/24298595/how-to-set-an-exact-repeating-alarm-on-api-19-kitkat

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