I want to make a time or date listener which for example invoke an activity every day at 9 AM. I am not sure what is the best way to do that? I know I can use Alarm Manager, but I don’t know how to make it repetitive?
Does anyone know? Thank you very much in advance.
Cheer 🙂
Use
setRepeating()and specify a repeat interval ofINTERVAL_DAY:The above code will set up an alarm that will go off 24 hours from right now and every 24 hours thereafter. To have it start at 9am, replace
ELAPSED_REALTIMEwithRTCand replaceSystemClock.elapsedRealtime() + AlarmManager.INTERVAL_DAYwith 9am (today or tomorrow), such as via aCalendarobject.