Services are app components that usually run in the background to perform operations. Services don’t have a UI. These can run continuously for some time, even after an app user switches to another app. Moreover, an app component can bind to a service to perform interprocess communication (IPC). Services can perform file I/O, play music, and handle network transactions in the background.

Let’s us explore Android services, their types, and the service life cycle methods.

Types of services

Android services are mainly of two types:

  • Started services: These continue to run even if the calling component, such as an activity, is destroyed. Examples of these services include sending notifications and downloading files.

  • Bound services: These allow other apps to bind to and interact with them to share some functionality. These services provide a client-server interface between an app component and themselves for sending requests and receiving results. More than one component can bind itself to the same service. For example, multiple music player apps can bind to a music playback service to access its functionality. The Android OS destroys bound services when all client components unbind themselves from the service.

Get hands-on with 1400+ tech skills courses.