📚 Encyclopedia

Android · updated 2026-11-02

Alarms and timers that ring on time (Android clock apps)

androidalarmmanagerexact-alarmsforeground-servicefull-screen-intentnotificationsclock

An alarm clock is the one kind of app Android still lets wake the phone at an exact minute, but only if it asks the right way. This article covers how to schedule, how to ring, and what to re-arm. It comes from Justin's Clock app (io.jhampton.clock, Kotlin + Compose, shipped 2026-10-27) and the midnight alarm in his Calendar app.

Scheduling

What clears alarms (re-arm on all of these)

AlarmManager forgets everything on reboot, and a wall-clock alarm computed from local time is wrong after a time-zone change. A manifest receiver should call sync() on BOOT_COMPLETED, MY_PACKAGE_REPLACED (an update cancels the app's alarms), TIME_SET, TIMEZONE_CHANGED and SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED. Call it on app start too.

A timer that ran out while the phone was off has a deadline in the past: on sync(), ring it immediately instead of scheduling it.

Ringing

Timers and stopwatches

Being the system's clock app

An ACTION_SET_ALARM, SET_TIMER, SHOW_ALARMS and SHOW_TIMERS intent filter (category DEFAULT) on the main activity makes voice assistants and other apps hand alarms and timers to it. adb shell am start -a android.intent.action.SET_TIMER --ei android.intent.extra.alarm.LENGTH 5 --ez android.intent.extra.alarm.SKIP_UI true is a quick end-to-end test on the emulator.

A daily midnight job

For something that must happen at a calendar boundary (the Calendar app's date icon, see A launcher icon that changes (today's date on a calendar icon)), arm an exact RTC_WAKEUP alarm for next local midnight plus a couple of seconds, do the work in the receiver, and re-arm from there, plus the same reboot, update, time and zone triggers as above. Tested by setting the emulator clock to 23:59:50 as root.

Gotchas

See also

Linked from

Sources: clock memory, repo ~/dev/clock (0.1.0), calendar memory (0.3.0 day icon), tldr posts #1858, #1871