Skip to content
Related Articles

Related Articles

How to Use Android Work Manager?

Improve Article
Save Article
Like Article
  • Last Updated : 19 Sep, 2021

We’ve taken it a step further in WorkManager 2.6 by adding support for Workers to operate in any process and allowing workers to be tied to a specific process. Multi-process functionality is very beneficial for programs that require Workers to operate in different processes. The majority of apps operate nicely in a single process. Those that require more than one process, on the other hand, have a difficult time coordinating work between processes. The WorkManager API makes it simple to plan deferrable, asynchronous activities that must be completed consistently. These APIs allow you to construct a task and provide it to WorkManager to execute when the work limits are fulfilled.

Define the Task

The Worker class is used to define work. The doWork() function executes asynchronously on a WorkManager-provided background thread.

What’s New in V2.6?

Starting with WorkManager 2.6, you may use RemoteListenableWorker or RemoteCoroutineWorker to tie a worker to a particular process. RemoteCoroutineWorker should be used for workers written in Kotlin. Otherwise, RemoteListenableWorker should be used. In this post, we’ll show how to create a Worker in Kotlin, however for a similar Java implementation,

See the example linked below:

A partialWorkMonitor can be constructed in the same way that a CoroutineWorker can. Instead of overriding doWork, you override doRemoteWork and then bind to a specific process using two extra arguments supplied as part of the input data when constructing the work request: ARGUMENT PACKAGE NAME and ARGUMENT CLASS NAME:


val primaryName =
val tertiaryName = ComponentName(PACKAGE_NAME, primaryName)
val data: Data = Data.Builder()
   .putString(NAME_OF_FILE, someName.packageName)
   .putString(NAME_OF_FILE, someName.className)
return OneTimeWorkRequestBuilder<ExampleRemoteCoroutineWorker>

Further, you must additionally provide the service definition in the AndroidManifest for each RemoteWorkerService, as follows:

<manifest ... >
            android:process=":someRandomWorker" />

            android:process=":anotherRandomWorker" />


Previously, if ActivityManager was unable to instantiate the JobService to begin a job, the job would be dropped quietly due to an underlying platform issue. When an application instance is created, WorkManager now guarantees that there is a backing scheduler task for every single WorkRequest by reconciling WorkRequest objects with jobs.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!