Menu

Android reminders that actually fire: exact alarms, SCHEDULE_EXACT_ALARM and rescheduling after reboot
📰

Android reminders that actually fire: exact alarms, SCHEDULE_EXACT_ALARM and rescheduling after reboot

DEV Community: mobile·Charles Hartmann·9 days ago
#mITPlb0R
#devtomobile#devto#dev#user#reminders
Reading 0:00
15s threshold

A reminder is a promise with a time on it. The user said "remind me at 9:00", and if the notification arrives at 9:40, or after the next reboot, or never, the promise is broken. Android gives you several ways to run code later, and each one trades precision for battery. This post picks the right one for each job and makes reminders survive the three things that kill them: Doze, reboots and permission changes.

The menu of "later"

Need Tool Precision

Deferrable work: sync, cleanup, a daily digest WorkManager Minutes to hours; runs when constraints allow

"Around this time" AlarmManager.set() / setAndAllowWhileIdle() Within an hour on Android 12+, unless battery saving delays it

"Within this window" AlarmManager.setWindow() Inside the window; short windows are usually stretched to 10 minutes

"At this minute", user-set setExactAndAllowWhileIdle() Nearly exact, even in Doze; needs exact alarm access

An alarm clock setAlarmClock() Exact; shown to the user as an upcoming alarm

Those figures come from…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.