RemoteWorkManager
abstract class RemoteWorkManager
A subset of androidx.work.WorkManager APIs that are available for apps that use multiple processes.
Summary
Public functions |
|
|---|---|
abstract RemoteWorkContinuation |
beginUniqueWork(This method allows you to begin unique chains of work for situations where you only want one chain with a given name to be active at a time. |
RemoteWorkContinuation |
beginUniqueWork(This method allows you to begin unique chains of work for situations where you only want one chain with a given name to be active at a time. |
abstract RemoteWorkContinuation |
beginWith(work: (Mutable)List<OneTimeWorkRequest!>)Begins a chain with one or more |
RemoteWorkContinuation |
beginWith(work: OneTimeWorkRequest)Begins a chain with one or more |
abstract ListenableFuture<Void!> |
Cancels all unfinished work. |
abstract ListenableFuture<Void!> |
cancelAllWorkByTag(tag: String)Cancels all unfinished work with the given tag. |
abstract ListenableFuture<Void!> |
cancelUniqueWork(uniqueWorkName: String)Cancels all unfinished work in the work chain with the given name. |
abstract ListenableFuture<Void!> |
cancelWorkById(id: UUID)Cancels work with the given id if it isn't finished. |
abstract ListenableFuture<Void!> |
enqueue(request: WorkRequest)Enqueues one item for background processing. |
abstract ListenableFuture<Void!> |
enqueue(requests: (Mutable)List<WorkRequest!>)Enqueues one or more items for background processing. |
abstract ListenableFuture<Void!> |
enqueueUniquePeriodicWork(This method allows you to enqueue a uniquely-named |
abstract ListenableFuture<Void!> |
enqueueUniqueWork(This method allows you to enqueue |
ListenableFuture<Void!> |
enqueueUniqueWork(This method allows you to enqueue |
java-static RemoteWorkManager |
getInstance(context: Context)Gets the instance of |
abstract ListenableFuture<(Mutable)List<WorkInfo!>!> |
getWorkInfos(workQuery: WorkQuery)Gets the |
Public functions
beginUniqueWork
abstract fun beginUniqueWork(
uniqueWorkName: String,
existingWorkPolicy: ExistingWorkPolicy,
work: (Mutable)List<OneTimeWorkRequest!>
): RemoteWorkContinuation
This method allows you to begin unique chains of work for situations where you only want one chain with a given name to be active at a time. For example, you may only want one sync operation to be active. If there is one pending, you can choose to let it run or replace it with your new work.
The uniqueWorkName uniquely identifies this set of work.
If this method determines that new work should be enqueued and run, all records of previous work with uniqueWorkName will be pruned. If this method determines that new work should NOT be run, then the entire chain will be considered a no-op.
If any work in the chain fails or is cancelled, all of its dependent work inherits that state and will never run. This is particularly important if you are using APPEND as your ExistingWorkPolicy.
| Parameters | |
|---|---|
uniqueWorkName: String |
A unique name which for this chain of work |
existingWorkPolicy: ExistingWorkPolicy |
An |
work: (Mutable)List<OneTimeWorkRequest!> |
One or more |
| Returns | |
|---|---|
RemoteWorkContinuation |
A |
beginUniqueWork
fun beginUniqueWork(
uniqueWorkName: String,
existingWorkPolicy: ExistingWorkPolicy,
work: OneTimeWorkRequest
): RemoteWorkContinuation
This method allows you to begin unique chains of work for situations where you only want one chain with a given name to be active at a time. For example, you may only want one sync operation to be active. If there is one pending, you can choose to let it run or replace it with your new work.
The uniqueWorkName uniquely identifies this set of work.
If this method determines that new work should be enqueued and run, all records of previous work with uniqueWorkName will be pruned. If this method determines that new work should NOT be run, then the entire chain will be considered a no-op.
If any work in the chain fails or is cancelled, all of its dependent work inherits that state and will never run. This is particularly important if you are using APPEND as your ExistingWorkPolicy.
| Parameters | |
|---|---|
uniqueWorkName: String |
A unique name which for this chain of work |
existingWorkPolicy: ExistingWorkPolicy |
|
work: OneTimeWorkRequest |
The |
| Returns | |
|---|---|
RemoteWorkContinuation |
A |
beginWith
abstract fun beginWith(work: (Mutable)List<OneTimeWorkRequest!>): RemoteWorkContinuation
Begins a chain with one or more OneTimeWorkRequests, which can be enqueued together in the future using enqueue.
If any work in the chain fails or is cancelled, all of its dependent work inherits that state and will never run.
| Parameters | |
|---|---|
work: (Mutable)List<OneTimeWorkRequest!> |
One or more |
| Returns | |
|---|---|
RemoteWorkContinuation |
A |
beginWith
fun beginWith(work: OneTimeWorkRequest): RemoteWorkContinuation
Begins a chain with one or more OneTimeWorkRequests, which can be enqueued together in the future using enqueue.
If any work in the chain fails or is cancelled, all of its dependent work inherits that state and will never run.
| Parameters | |
|---|---|
work: OneTimeWorkRequest |
One or more |
| Returns | |
|---|---|
RemoteWorkContinuation |
A |
cancelAllWork
abstract fun cancelAllWork(): ListenableFuture<Void!>
Cancels all unfinished work. Use this method with extreme caution! By invoking it, you will potentially affect other modules or libraries in your codebase. It is strongly recommended that you use one of the other cancellation methods at your disposal.
Upon cancellation, onStopped will be invoked for any affected workers.
| Returns | |
|---|---|
ListenableFuture<Void!> |
A |
cancelAllWorkByTag
abstract fun cancelAllWorkByTag(tag: String): ListenableFuture<Void!>
Cancels all unfinished work with the given tag. Note that cancellation is a best-effort policy and work that is already executing may continue to run. Upon cancellation, onStopped will be invoked for any affected workers.
| Parameters | |
|---|---|
tag: String |
The tag used to identify the work |
| Returns | |
|---|---|
ListenableFuture<Void!> |
An |
cancelUniqueWork
abstract fun cancelUniqueWork(uniqueWorkName: String): ListenableFuture<Void!>
Cancels all unfinished work in the work chain with the given name. Note that cancellation is a best-effort policy and work that is already executing may continue to run. Upon cancellation, onStopped will be invoked for any affected workers.
| Parameters | |
|---|---|
uniqueWorkName: String |
The unique name used to identify the chain of work |
| Returns | |
|---|---|
ListenableFuture<Void!> |
A |
cancelWorkById
abstract fun cancelWorkById(id: UUID): ListenableFuture<Void!>
Cancels work with the given id if it isn't finished. Note that cancellation is a best-effort policy and work that is already executing may continue to run. Upon cancellation, onStopped will be invoked for any affected workers.
| Parameters | |
|---|---|
id: UUID |
The id of the work |
| Returns | |
|---|---|
ListenableFuture<Void!> |
A |
enqueue
abstract fun enqueue(request: WorkRequest): ListenableFuture<Void!>
Enqueues one item for background processing.
| Parameters | |
|---|---|
request: WorkRequest |
The |
| Returns | |
|---|---|
ListenableFuture<Void!> |
A |
enqueue
abstract fun enqueue(requests: (Mutable)List<WorkRequest!>): ListenableFuture<Void!>
Enqueues one or more items for background processing.
| Parameters | |
|---|---|
requests: (Mutable)List<WorkRequest!> |
One or more |
| Returns | |
|---|---|
ListenableFuture<Void!> |
A |
enqueueUniquePeriodicWork
abstract fun enqueueUniquePeriodicWork(
uniqueWorkName: String,
existingPeriodicWorkPolicy: ExistingPeriodicWorkPolicy,
periodicWork: PeriodicWorkRequest
): ListenableFuture<Void!>
This method allows you to enqueue a uniquely-named PeriodicWorkRequest, where only one PeriodicWorkRequest of a particular name can be active at a time. For example, you may only want one sync operation to be active. If there is one pending, you can choose to let it run or replace it with your new work.
The uniqueWorkName uniquely identifies this PeriodicWorkRequest.
| Parameters | |
|---|---|
uniqueWorkName: String |
A unique name which for this operation |
existingPeriodicWorkPolicy: ExistingPeriodicWorkPolicy |
|
periodicWork: PeriodicWorkRequest |
A |
| Returns | |
|---|---|
ListenableFuture<Void!> |
An |
enqueueUniqueWork
abstract fun enqueueUniqueWork(
uniqueWorkName: String,
existingWorkPolicy: ExistingWorkPolicy,
work: (Mutable)List<OneTimeWorkRequest!>
): ListenableFuture<Void!>
This method allows you to enqueue work requests to a uniquely-named RemoteWorkContinuation, where only one continuation of a particular name can be active at a time. For example, you may only want one sync operation to be active. If there is one pending, you can choose to let it run or replace it with your new work.
The uniqueWorkName uniquely identifies this RemoteWorkContinuation.
| Parameters | |
|---|---|
uniqueWorkName: String |
A unique name which for this operation |
existingWorkPolicy: ExistingWorkPolicy |
|
work: (Mutable)List<OneTimeWorkRequest!> |
|
| Returns | |
|---|---|
ListenableFuture<Void!> |
A |
enqueueUniqueWork
fun enqueueUniqueWork(
uniqueWorkName: String,
existingWorkPolicy: ExistingWorkPolicy,
work: OneTimeWorkRequest
): ListenableFuture<Void!>
This method allows you to enqueue work requests to a uniquely-named RemoteWorkContinuation, where only one continuation of a particular name can be active at a time. For example, you may only want one sync operation to be active. If there is one pending, you can choose to let it run or replace it with your new work.
The uniqueWorkName uniquely identifies this RemoteWorkContinuation.
| Parameters | |
|---|---|
uniqueWorkName: String |
A unique name which for this operation |
existingWorkPolicy: ExistingWorkPolicy |
An |
work: OneTimeWorkRequest |
The |
| Returns | |
|---|---|
ListenableFuture<Void!> |
A |
getInstance
java-static fun getInstance(context: Context): RemoteWorkManager
Gets the instance of RemoteWorkManager which provides a subset of WorkManager APIs that are safe to use for apps that use multiple processes.
| Parameters | |
|---|---|
context: Context |
The application context. |
| Returns | |
|---|---|
RemoteWorkManager |
The instance of |
getWorkInfos
abstract fun getWorkInfos(workQuery: WorkQuery): ListenableFuture<(Mutable)List<WorkInfo!>!>
Gets the ListenableFuture of the List of WorkInfo for all work referenced by the WorkQuery specification.
| Parameters | |
|---|---|
workQuery: WorkQuery |
The work query specification |
| Returns | |
|---|---|
ListenableFuture<(Mutable)List<WorkInfo!>!> |
A |