public abstract class WorkContinuation

A class that allows you to chain together OneTimeWorkRequests. WorkContinuations allow the user to create arbitrary acyclic graphs of work dependencies. You can add dependent work to a WorkContinuation by invoking then or its variants. This returns a new WorkContinuation.

To construct more complex graphs, combine or its variants can be used to return a WorkContinuation with the input WorkContinuations as prerequisites. To create a graph like this:

    A       C
    |       |
    B       D
    |       |
    +-------+
        |
E    

you would write the following:

 WorkContinuation left = workManager.beginWith(A).then(B);
 WorkContinuation right = workManager.beginWith(C).then(D);
 WorkContinuation final = WorkContinuation.combine(Arrays.asList(left, right)).then(E);
 final.enqueue();

Not that enqueuing a WorkContinuation enqueues all previously-unenqueued prerequisites. You must call enqueue to inform WorkManager to actually enqueue the work graph. As usual, enqueues are asynchronous - you can observe or block on the returned Operation if you need to be informed about its completion.

Because of the fluent nature of this class, its existence should be invisible in most cases.

Summary

Public constructors

Public methods

combine

public static @NonNull WorkContinuation combine(@NonNull List<WorkContinuation> continuations)

Combines multiple WorkContinuations as prerequisites for a new WorkContinuation to allow for complex chaining. For example, to create a graph like this:

    A       C
    |       |
    B       D
    |       |
    +-------+
        |
E    

you would write the following:

 WorkContinuation left = workManager.beginWith(A).then(B);
 WorkContinuation right = workManager.beginWith(C).then(D);
 WorkContinuation final = WorkContinuation.combine(Arrays.asList(left, right)).then(E);
 final.enqueue();

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-08-27 UTC.