Schedule tasks with WorkManager Part of Android Jetpack.
The WorkManager API makes it easy to schedule deferrable, asynchronous tasks that are expected to run even if the app exits or device restarts.
- Backwards compatible up to API 14
- Uses JobScheduler on devices with API 23+
- Uses a combination of BroadcastReceiver + AlarmManager on devices with API 14-22
- Add work constraints like network availability or charging status
- Schedule asynchronous one-off or periodic tasks
- Monitor and manage scheduled tasks
- Chain tasks together
- Guarantees task execution, even if the app or device restarts
WorkManager is intended for tasks that are deferrable—that is, not required to run immediately—and required to run reliably even if the app exits or the device restarts. For example:
- Sending logs or analytics to backend services
- Periodically syncing application data with a server
WorkManager is not intended for in-process background work that can safely be terminated if the app process goes away or for tasks that require immediate execution. Please review the background processing guide to see which solution meets your needs.
- Defining your WorkRequests
- Observing the status of your work
- Chaining work together
- Cancelling and stopping work
- Handling recurring work
- Handling unique work
- Testing your Workers
- Customizing WorkManager
- Threading in WorkManager
- WorkManagerSample, a simple image-processing app
- Sunflower, a demo app demonstrating best practices with various architecture components, including WorkManager.
- Working with WorkManager, from the 2018 Android Dev Summit