A developer wants their Android app to keep running persistently in the background without being killed by the system, displaying a persistent notification. Which service type is specifically designed for this long-running foreground work?
- A.A. A regular background Service started with startService()
- B.C. A BoundService that maintains an ongoing IPC connection with the main activity
- C.B. A Foreground Service started with startForeground(), which requires a persistent user-visible notification and prevents the system from killing the service under normal memory pressure
- D.D. A JobIntentService which runs as a background job managed by the JobScheduler
Why C is correct
Foreground Services (startForeground()) are Android's mechanism for long-running background operations that are important enough to warrant persistent user notification. The mandatory visible notification informs users that the app is actively running, addressing the transparency concern with background processes. Regular background Services can be killed at any time under memory pressure. BoundServices are tied to client component lifecycle. JobIntentService/JobScheduler is for deferrable background work, not persistent real-time operations.
Know someone studying for Mobile Security Fundamentals? Send them this one.