Exact alarms

Background work and notifications Mid-level Kotlin 2.0+ API 31+ Reviewed By Best Latest Apps

Pick the fix

Calling setExactAndAllowWhileIdle throws SecurityException on Android 14 for new users. Best handling?

Options
Hint 1 of 1

Who grants SCHEDULE_EXACT_ALARM on Android 14?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Check canScheduleExactAlarms(), and if false explain and open the exact-alarm settings screen

Correct. The permission is off by default and the user must grant it.

Why not the others?
  • B Catch the exception and ignore it. The reminder silently never fires.
  • C Request USE_EXACT_ALARM in every app. Play allows it only for alarm and calendar apps.
  • D Use Handler.postDelayed. It dies with the process.

30-second answer

Exact alarms fire at a precise time even in Doze, but they cost battery, so they're reserved for user-facing timing like alarm clocks, calendar reminders and timers. Since Android 12 you need SCHEDULE_EXACT_ALARM, which users can revoke, and since Android 14 it's denied by default for most new installs. Alarm and calendar apps can use USE_EXACT_ALARM instead. Everything else should use inexact alarms or WorkManager.

Practise saying it · 30 s. No recording, just a timer

Explain exact alarms.

Say your answer out loud, then check which of these points you covered:

  • For user-facing timing only
  • SCHEDULE_EXACT_ALARM, off by default on 14
  • Check canScheduleExactAlarms
  • Reschedule after reboot

Deep dive

Check alarmManager.canScheduleExactAlarms() before scheduling, and send users to settings if needed.

Listen for ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED to reschedule.

Alarms are cleared on reboot; reschedule from a BOOT_COMPLETED receiver.

setWindow gives a time window when exact isn't necessary.

Common mistakes

  • Using exact alarms for sync.
  • Not checking canScheduleExactAlarms and crashing with SecurityException.
  • Forgetting to reschedule after reboot.

Senior take & follow-ups

Mention the permission history and the Play policy limit.

Follow-up questions

Think of your answer first, then open the hint.

  1. What happens to alarms after a reboot?

    Show hint

    They're gone; reschedule them on BOOT_COMPLETED.

  2. Who can use USE_EXACT_ALARM?

    Show hint

    Alarm clock and calendar apps, per Play policy.

Suggest a fix if something here is wrong or out of date.