Services are Android Framework components meant for running background tasks that don’t need a visual component, therefore they do not provide a User Interface (UI). An Activity can start a Service which can then continue to run, even after the Activity is shut down. They are ideal for loading and processing data in the background, regardless of whether any of the app’s Activities are open. A common example of this is how you can receive notifications when an app is not running.
A Service should be used when the task is decoupled from (does not directly affect) the UI, and needs to exist even when there is no UI.
There are 3 ways to start a Service:
- Start – manually from a context e.g. Activity. Executes but will not normally communicate back to the component that started it.
- Schedule – if you want to have a Service execute at some point in the future, or when some conditions are met, you can create a JobService. You can control when this starts via a Scheduler e.g. JobScheduler
- Bind – offers a client-server-like interface, with the Service being the server, and the various components being bound to the Service being the clients. Components bind to the Service via the bindService() method. These Services can easily communicate with the components that are bound to them (unlike the started Services above). An example might be an audio player, where the Service plays the audio while the Activity controls the UI, with the UI being updated as to the progress of the audio file play. Likewise, pressing the Pause button will mean sending a command to the Service.
A Service can be both STARTED and BOUND.
If you want to run a Service in a completely separate thread you can use an Intent Service.
The Lifecycle of a Started Service is depicted below:

