Doze and App Standby

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

Pick the fix

A reminder app's periodic WorkManager check fires hours late overnight. What fits?

Options
Hint 1 of 1

Is this deferrable work or a time-critical alert?

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

Show answer

Answer: A Schedule the reminder with an exact alarm (setExactAndAllowWhileIdle) and the exact-alarm permission

Correct. User-facing reminders at a set time are what exact alarms are for.

Why not the others?
  • B Lower the periodic interval to 1 minute. The minimum is 15 minutes, and Doze still defers it.
  • C Ask users to disable battery optimisation. Heavy-handed and often refused.
  • D Keep a foreground service running all night. Drains battery and annoys users.

30-second answer

In Doze, when the device is still and unplugged with the screen off, the system defers jobs, alarms and network access to short maintenance windows. App Standby buckets (active, working set, frequent, rare, restricted) limit how often each app's jobs and alarms run based on how recently it was used. Work isn't lost, but it's delayed, sometimes for hours.

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

Explain Doze and App Standby.

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

  • Doze defers work to maintenance windows
  • Standby buckets limit frequency
  • High-priority FCM can wake
  • Test with adb

Deep dive

High-priority FCM messages can wake an app briefly even in Doze.

setExactAndAllowWhileIdle alarms fire in Doze but are rate-limited.

Test with adb shell dumpsys deviceidle force-idle and am set-standby-bucket.

Battery optimisation exemptions are only for specific use cases on Play.

Common mistakes

  • Expecting periodic work to run on time overnight.
  • Asking every user to disable battery optimisation.
  • Polling a server from the background instead of using push.

Senior take & follow-ups

Explain delays rather than 'background is broken', and name the test commands.

Follow-up questions

Think of your answer first, then open the hint.

  1. How do you test Doze?

    Show hint

    adb shell dumpsys deviceidle force-idle.

  2. What wakes an app reliably?

    Show hint

    A high-priority FCM message, used sparingly.

Similar on iOS: Background sync without draining the battery iOS decides background run time itself; there's no equivalent of standby buckets you can query.

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