SynchronousWorkManager

interface SynchronousWorkManager
androidx.work.SynchronousWorkManager

Blocking methods for WorkManager operations. These methods are expected to be called from a background thread.

Summary

Public methods
abstract MutableList<WorkStatus!>!

Gets the WorkStatus for all work for the chain of work with a given unique name in a synchronous fashion.

abstract Unit

Cancels all unfinished work with the given tag in a synchronous fashion.

abstract MutableList<WorkStatus!>!

Gets the WorkStatus for all work with a given tag in a synchronous fashion.

abstract Unit
cancelUniqueWorkSync(uniqueWorkName: String)

Cancels all unfinished work in the work chain with the given name in a synchronous fashion.

abstract WorkStatus!

Gets the WorkStatus of a given work id in a synchronous fashion.

abstract Unit

Cancels work with the given id in a synchronous fashion if it isn't finished.

abstract Unit
enqueueSync(vararg workRequest: WorkRequest!)

Enqueues one or more WorkRequest in a synchronous fashion.

abstract Unit
enqueueSync(workRequest: MutableList<out WorkRequest!>)

Enqueues the List of WorkRequest in a synchronous fashion.

Public methods

getStatusesForUniqueWorkSync

abstract fun getStatusesForUniqueWorkSync(uniqueWorkName: String): MutableList<WorkStatus!>!

Gets the WorkStatus for all work for the chain of work with a given unique name in a synchronous fashion. This method is expected to be called from a background thread.

Parameters
uniqueWorkName String: The unique name used to identify the chain of work
Return
MutableList<WorkStatus!>!: A list of WorkStatus for work in the chain named uniqueWorkName

cancelAllWorkByTagSync

abstract fun cancelAllWorkByTagSync(tag: String): Unit

Cancels all unfinished work with the given tag in a synchronous fashion. Note that cancellation is dependent on timing (for example, the work could have completed in a different thread just as you issue this call). Use #getStatusByIdSync(UUID) to find out the actual state of the work after this call. This method is expected to be called from a background thread.

Parameters
tag String: The tag used to identify the work

getStatusesByTagSync

abstract fun getStatusesByTagSync(tag: String): MutableList<WorkStatus!>!

Gets the WorkStatus for all work with a given tag in a synchronous fashion. This method is expected to be called from a background thread.

Parameters
tag String: The tag of the work
Return
MutableList<WorkStatus!>!: A list of WorkStatus for work tagged with tag

cancelUniqueWorkSync

abstract fun cancelUniqueWorkSync(uniqueWorkName: String): Unit

Cancels all unfinished work in the work chain with the given name in a synchronous fashion. Note that cancellation is dependent on timing (for example, the work could have completed in a different thread just as you issue this call). Use #getStatusByIdSync(UUID) to find out the actual state of the work after this call. This method is expected to be called from a background thread.

Parameters
uniqueWorkName String: The unique name used to identify the chain of work

getStatusByIdSync

abstract fun getStatusByIdSync(id: UUID): WorkStatus!

Gets the WorkStatus of a given work id in a synchronous fashion. This method is expected to be called from a background thread.

Parameters
id UUID: The id of the work
Return
WorkStatus!: A WorkStatus associated with id

cancelWorkByIdSync

abstract fun cancelWorkByIdSync(id: UUID): Unit

Cancels work with the given id in a synchronous fashion if it isn't finished. Note that cancellation is dependent on timing (for example, the work could have completed in a different thread just as you issue this call). Use #getStatusByIdSync(UUID) to find out the actual state of the work after this call. This method is expected to be called from a background thread.

Parameters
id UUID: The id of the work

enqueueSync

abstract fun enqueueSync(vararg workRequest: WorkRequest!): Unit

Enqueues one or more WorkRequest in a synchronous fashion. This method is expected to be called from a background thread and, upon successful execution, you can rely on that the work has been enqueued.

Parameters
workRequest WorkRequest!: The Array of WorkRequest

enqueueSync

abstract fun enqueueSync(workRequest: MutableList<out WorkRequest!>): Unit

Enqueues the List of WorkRequest in a synchronous fashion. This method is expected to be called from a background thread and, upon successful execution, you can rely on that the work has been enqueued.

Parameters
workRequest MutableList<out WorkRequest!>: The List of WorkRequest