mediumConceptDesignMidSenior
You need to run background work on Android - how do you choose between WorkManager, a foreground service, and AlarmManager?
4 min readUpdated 2026-08-15
Answer
Short answer
WorkManager is the default for deferrable work that must eventually run, a foreground service is for work the user is actively aware of right now, and AlarmManager is only for work that must fire at a specific wall-clock time regardless of system state.
Keep android explicit in the answer because that is the concept the interviewer is actually trying to test. A good android explanation names the trade-off, the failure mode, and the evidence you would use before choosing.
Was this answer helpful?
Likely follow-ups
- What happens to a running WorkManager job if the OS kills the app process partway through?
- Why does starting a foreground service without immediately calling startForeground() crash on modern Android?
- How does WorkManager's own internal use of AlarmManager and JobScheduler change your answer about when to use AlarmManager directly?
- What expedited work in WorkManager is for, and why isn't it a substitute for a foreground service?
Related questions
- How do you leverage WorkManager to guarantee execution, handle conflict resolution, and optimise battery usage in an offline-first Android application requiring bidirectional synchronisation?hardAlso on android and workmanager3 min
- An Android app queues actions while offline. After the process is killed and restarted, some actions sync twice and the user sees duplicate orders. How do you design the fix?hardAlso on workmanager4 min
- A deep link opens the right screen when the app is in the background and the wrong one when the app was killed. How do you test for that?mediumAlso on android5 min
- How do you choose which devices to test on, and what will an emulator never tell you?mediumAlso on android5 min