Understanding Services and Work Managers
Learn about creating and using services and work managers in Android.
We'll cover the following
Introduction
There are scenarios where we might need components that have their own lifecycle and can work independently to perform a job. Android framework provides native components that can be used for this purpose.
Let’s learn how to create and perform long-running operations in the background using these components.
Services
A service is a core Android component that allows long-running tasks to execute in the background. Similar to an activity, the service has its own lifecycle and associated callback methods. Unlike an activity or a fragment, we don’t need to keep the service in the foreground during its lifecycle. For example, if we need to keep track of a user’s GPS location while the app is running in the background, we could use a service to monitor their location.
The service lifecycle is much simpler than an activity. The diagram below shows the service lifecycle methods.
Get hands-on with 1200+ tech skills courses.