lightbulb_outline Please take our October 2018 developer survey. Start survey

WorkContinuation

public abstract class WorkContinuation
extends Object

java.lang.Object
   ↳ androidx.work.WorkContinuation


An opaque class that allows you to chain together OneTimeWorkRequest.

Summary

Public constructors

WorkContinuation()

Public methods

static WorkContinuation combine(WorkContinuation... continuations)

Combines multiple WorkContinuations to allow for complex chaining.

static WorkContinuation combine(OneTimeWorkRequest work, WorkContinuation... continuations)

Combines multiple WorkContinuations to allow for complex chaining using the OneTimeWorkRequest provided.

static WorkContinuation combine(List<WorkContinuation> continuations)

Combines multiple WorkContinuations to allow for complex chaining.

static WorkContinuation combine(OneTimeWorkRequest work, List<WorkContinuation> continuations)

Combines multiple WorkContinuations to allow for complex chaining using the OneTimeWorkRequest provided.

abstract ListenableFuture<Void> enqueue()

Enqueues the instance of WorkContinuation on the background thread.

abstract ListenableFuture<List<WorkStatus>> getStatuses()

Returns a ListenableFuture of a List of WorkStatus that provides information about work, their progress, and any resulting output in the WorkContinuation.

abstract LiveData<List<WorkStatus>> getStatusesLiveData()

Returns a LiveData list of WorkStatus that provides information about work, their progress, and any resulting output.

final WorkContinuation then(OneTimeWorkRequest... work)

Adds new OneTimeWorkRequest items that depend on the successful completion of all previously added OneTimeWorkRequest.

abstract WorkContinuation then(List<OneTimeWorkRequest> work)

Adds new OneTimeWorkRequest items that depend on the successful completion of all previously added OneTimeWorkRequest.

Inherited methods

Public constructors

WorkContinuation

public WorkContinuation ()

Public methods

combine

public static WorkContinuation combine (WorkContinuation... continuations)

Combines multiple WorkContinuations to allow for complex chaining.

Parameters
continuations WorkContinuation: Two or more WorkContinuations that are prerequisites for the return value

Returns
WorkContinuation A WorkContinuation that allows further chaining

combine

public static WorkContinuation combine (OneTimeWorkRequest work, 
                WorkContinuation... continuations)

Combines multiple WorkContinuations to allow for complex chaining using the OneTimeWorkRequest provided.

Parameters
work OneTimeWorkRequest: The OneTimeWorkRequest which depends on the successful completion of the provided WorkContinuations

continuations WorkContinuation: Two or more WorkContinuations that are prerequisites for the OneTimeWorkRequest provided.

Returns
WorkContinuation A WorkContinuation that allows further chaining

combine

public static WorkContinuation combine (List<WorkContinuation> continuations)

Combines multiple WorkContinuations to allow for complex chaining.

Parameters
continuations List: One or more WorkContinuations that are prerequisites for the return value

Returns
WorkContinuation A WorkContinuation that allows further chaining

combine

public static WorkContinuation combine (OneTimeWorkRequest work, 
                List<WorkContinuation> continuations)

Combines multiple WorkContinuations to allow for complex chaining using the OneTimeWorkRequest provided.

Parameters
work OneTimeWorkRequest: The OneTimeWorkRequest which depends on the successful completion of the provided WorkContinuations

continuations List: Two or more WorkContinuations that are prerequisites for the OneTimeWorkRequest provided.

Returns
WorkContinuation A WorkContinuation that allows further chaining

enqueue

public abstract ListenableFuture<Void> enqueue ()

Enqueues the instance of WorkContinuation on the background thread.

Returns
ListenableFuture<Void> A ListenableFuture that completes when the enqueue operation is completed

getStatuses

public abstract ListenableFuture<List<WorkStatus>> getStatuses ()

Returns a ListenableFuture of a List of WorkStatus that provides information about work, their progress, and any resulting output in the WorkContinuation.

Returns
ListenableFuture<List<WorkStatus>> A ListenableFuture of a List of WorkStatuses

getStatusesLiveData

public abstract LiveData<List<WorkStatus>> getStatusesLiveData ()

Returns a LiveData list of WorkStatus that provides information about work, their progress, and any resulting output. If state or outputs of any of the jobs in this chain changes, any attached Observers will trigger.

Returns
LiveData<List<WorkStatus>> A LiveData containing a list of WorkStatuses

then

public final WorkContinuation then (OneTimeWorkRequest... work)

Adds new OneTimeWorkRequest items that depend on the successful completion of all previously added OneTimeWorkRequest.

Parameters
work OneTimeWorkRequest: One or more OneTimeWorkRequest to add to the WorkContinuation

Returns
WorkContinuation A WorkContinuation that allows for further chaining of dependent OneTimeWorkRequest

then

public abstract WorkContinuation then (List<OneTimeWorkRequest> work)

Adds new OneTimeWorkRequest items that depend on the successful completion of all previously added OneTimeWorkRequest.

Parameters
work List: One or more OneTimeWorkRequest to add to the WorkContinuation

Returns
WorkContinuation A WorkContinuation that allows for further chaining of dependent OneTimeWorkRequest