ListenableWorker.Result

public abstract class ListenableWorker.Result


The result of a ListenableWorker's computation. Call success, failure, or retry or one of their variants to generate an object indicating what happened in your background work.

Summary

Public methods

static @NonNull ListenableWorker.Result

Returns an instance of Result that can be used to indicate that the work completed with a permanent failure.

static @NonNull ListenableWorker.Result
failure(@NonNull Data outputData)

Returns an instance of Result that can be used to indicate that the work completed with a permanent failure.

abstract @NonNull Data
static @NonNull ListenableWorker.Result

Returns an instance of Result that can be used to indicate that the work encountered a transient failure and should be retried with backoff specified in setBackoffCriteria.

static @NonNull ListenableWorker.Result

Returns an instance of Result that can be used to indicate that the work completed successfully.

static @NonNull ListenableWorker.Result
success(@NonNull Data outputData)

Returns an instance of Result that can be used to indicate that the work completed successfully.

Public methods

failure

Added in 1.0.0
public static @NonNull ListenableWorker.Result failure()

Returns an instance of Result that can be used to indicate that the work completed with a permanent failure. Any work that depends on this will also be marked as failed and will not be run. If you need child workers to run, you need to use success or success; failure indicates a permanent stoppage of the chain of work.

Returns
@NonNull ListenableWorker.Result

An instance of Result indicating failure when executing work

failure

Added in 1.0.0
public static @NonNull ListenableWorker.Result failure(@NonNull Data outputData)

Returns an instance of Result that can be used to indicate that the work completed with a permanent failure. Any work that depends on this will also be marked as failed and will not be run. If you need child workers to run, you need to use success or success; failure indicates a permanent stoppage of the chain of work.

Parameters
@NonNull Data outputData

A Data object that can be used to keep track of why the work failed

Returns
@NonNull ListenableWorker.Result

An instance of Result indicating failure when executing work

getOutputData

Added in 2.7.0
public abstract @NonNull Data getOutputData()
Returns
@NonNull Data

The output Data which will be merged into the input Data of any OneTimeWorkRequest that is dependent on this work request.

retry

Added in 1.0.0
public static @NonNull ListenableWorker.Result retry()

Returns an instance of Result that can be used to indicate that the work encountered a transient failure and should be retried with backoff specified in setBackoffCriteria.

Returns
@NonNull ListenableWorker.Result

An instance of Result indicating that the work needs to be retried

success

Added in 1.0.0
public static @NonNull ListenableWorker.Result success()

Returns an instance of Result that can be used to indicate that the work completed successfully. Any work that depends on this can be executed as long as all of its other dependencies and constraints are met.

Returns
@NonNull ListenableWorker.Result

An instance of Result indicating successful execution of work

success

Added in 1.0.0
public static @NonNull ListenableWorker.Result success(@NonNull Data outputData)

Returns an instance of Result that can be used to indicate that the work completed successfully. Any work that depends on this can be executed as long as all of its other dependencies and constraints are met.

Parameters
@NonNull Data outputData

A Data object that will be merged into the input Data of any OneTimeWorkRequest that is dependent on this work

Returns
@NonNull ListenableWorker.Result

An instance of Result indicating successful execution of work