The WorkManager API makes it easy to specify deferrable, asynchronous tasks and when they should run. These APIs let you create a task and hand it off to WorkManager to run immediately or at an appropriate time.
WorkManager chooses the appropriate way to run your task based on such factors
as the device API level and the app state. If WorkManager executes one of your
tasks while the app is running, WorkManager can run your task in a new thread in
your app's process. If your app is not running, WorkManager chooses an
appropriate way to schedule a background task--depending on the device API level and
included dependencies, WorkManager might use
AlarmManager. You don't need to
write device logic to figure
out what capabilities the device has and choose an appropriate API; instead, you
can just hand your task off to WorkManager and let it choose the best option.
- WorkManager basics
- Use WorkManager to schedule single tasks that run under the circumstances you choose, or recurring tasks that run at a specified interval.
- WorkManager advanced features
- Set up chained sequences of tasks, set up tasks that pass and return values, and set up named, unique work sequences.