The Android Developer Challenge is back! Submit your idea before December 2.

Operation

interface Operation
androidx.work.Operation

An object that provides information about the execution of an asynchronous command being performed by WorkManager. Operations are generally tied to enqueue or cancel commands; when you call one of those commands, they occur asynchronously. You can observe or await these commands by using the returned Operation.

Summary

Nested classes

abstract

The lifecycle state of an Operation.

Public methods

abstract ListenableFuture<Operation.State.SUCCESS!>

Gets a ListenableFuture for the terminal state of the Operation.

abstract LiveData<Operation.State!>

Gets a LiveData of the Operation State.

Extension functions

From androidx.work
suspend Operation.State.SUCCESS!

Awaits an Operation without blocking a thread.

Public methods

getResult

@NonNull abstract fun getResult(): ListenableFuture<Operation.State.SUCCESS!>

Gets a ListenableFuture for the terminal state of the Operation. This will only resolve with a State.SUCCESS. The State.FAILURE state will come through as a Throwable on the ListenableFuture. State.IN_PROGRESS will never be reported as it's not a terminal state.

Call ListenableFuture#get() to block until the Operation reaches a terminal state.

Return
ListenableFuture<Operation.State.SUCCESS!>: A ListenableFuture with information about Operation's State.SUCCESS state.

getState

@NonNull abstract fun getState(): LiveData<Operation.State!>

Gets a LiveData of the Operation State.

Return
LiveData<Operation.State!>: A LiveData of the Operation State; you must use LiveData#observe(LifecycleOwner, Observer) to receive updates