Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
858 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...