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 BoundService holding an IPC connection to the main activity (the binding keeps a reference alive), and the system spares the process because a bound client counts as a live user of the service
- 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
- C.A regular background Service started with startService (the classic entry point), and the platform keeps it running because a started service outranks a cached process in the low-memory killer
- D.A JobIntentService dispatched through JobScheduler (the compatibility wrapper Google shipped for older releases), and the work survives because the scheduler restarts any job that the system had to stop
Why B is correct