WorkManager is an API that makes it easy
to schedule deferrable, asynchronous tasks that are expected to
run even if the app exits or the device restarts. The WorkManager API is a
suitable and recommended replacement for all previous Android background
scheduling APIs, including
FirebaseJobDispatcher,
GcmNetworkManager,
and Job Scheduler. WorkManager
incorporates the features of its predecessors in a modern, consistent API that
works back to API level 14 while also being conscious of battery life.

Under the hood WorkManager uses an underlying job dispatching service based on
the following criteria:

Note: If your app targets Android 10 (API level 29) or above, your
FirebaseJobDispatcher and GcmNetworkManager API calls will no longer work on
devices running Android Marshmallow (6.0) and above. Follow the migration
guides for
FirebaseJobDispatcher
and GcmNetworkManager
for guidance on migrating. Also, see the Unifying Background Task Scheduling on
Android
announcement for more information regarding their
deprecation.

Features

In addition to providing a simpler and consistent API, WorkManager has a
number of other key benefits, including:

Work Constraints

Declaratively define the optimal conditions for your work to run using Work
Constraints.
(For example, run only when the device is Wi-Fi, when the
device idle, or when it has sufficient storage space, etc.)

Robust Scheduling

WorkManager allows you to schedule
work to run one-
time or
repeatedly using flexible
scheduling windows. Work can be tagged and named as well, allowing you to
schedule unique, replaceable, work and monitor or cancel groups of work
together. Scheduled work is stored in an internally managed SQLite database and
WorkManager takes care of ensuring that this work persists and is rescheduled
across device reboots. In addition, WorkManager adheres to power-saving
features and best practices like Doze mode, so you don’t have to worry about it.

Use WorkManager for Deferrable and Reliable Work

WorkManager is intended for work that is 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 work that requires immediate
execution. Please review the background processing guide to
see which solution meets your needs.