Services & Background Work
ANDROID › Components
Choosing and using Services, foreground services, and WorkManager for correct background execution.
Interviewers probe this to see whether you can pick the right background mechanism under modern Android's strict background-execution limits instead of reaching for a raw Service. Expect questions on started vs bound services, why foreground services need a notification and a declared type, and when WorkManager beats AlarmManager or JobScheduler. They want to know you understand persistence, constraints, and the platform restrictions added across API 26 through 34.
What this covers
- Started vs bound services: lifecycle, onStartCommand return flags, onBind/IBinder, and stopping correctly
- Foreground services: notification requirement, startForeground timing, foregroundServiceType, and per-version restrictions
- Background execution limits since API 26 and why a plain background Service is usually wrong
- WorkManager for deferrable, guaranteed work: constraints, chaining, periodic work, and persistence across reboot
- Choosing between WorkManager, AlarmManager, JobScheduler, and coroutines for a given task
- Service runs on the main thread by default; offload blocking work to avoid ANRs
Study this topic
- Services & Background Work explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Services & Background Work interview questions and answers