OneTimeWorkRequest.Builder


public final class OneTimeWorkRequest.Builder extends WorkRequest.Builder


Builder for OneTimeWorkRequests.

Summary

Public constructors

Creates a builder for OneTimeWorkRequests.

Public methods

final @NonNull OneTimeWorkRequest.Builder

Specifies the InputMerger class name for this OneTimeWorkRequest.

Inherited methods

From androidx.work.WorkRequest.Builder
final @NonNull OneTimeWorkRequest.Builder

Adds a tag for the work.

final @NonNull OneTimeWorkRequest

Builds a WorkRequest based on this Builder.

final @NonNull OneTimeWorkRequest.Builder

Specifies that the results of this work should be kept for at least the specified amount of time.

final @NonNull OneTimeWorkRequest.Builder
keepResultsForAtLeast(long duration, @NonNull TimeUnit timeUnit)

Specifies that the results of this work should be kept for at least the specified amount of time.

final @NonNull OneTimeWorkRequest.Builder
@RequiresApi(value = 26)
setBackoffCriteria(
    @NonNull BackoffPolicy backoffPolicy,
    @NonNull Duration duration
)

Sets the backoff policy and backoff delay for the work.

final @NonNull OneTimeWorkRequest.Builder
setBackoffCriteria(
    @NonNull BackoffPolicy backoffPolicy,
    long backoffDelay,
    @NonNull TimeUnit timeUnit
)

Sets the backoff policy and backoff delay for the work.

final @NonNull OneTimeWorkRequest.Builder

Adds constraints to the WorkRequest.

@NonNull OneTimeWorkRequest.Builder

Marks the WorkRequest as important to the user.

final @NonNull OneTimeWorkRequest.Builder

Sets a unique identifier for this unit of work.

@NonNull OneTimeWorkRequest.Builder
@RequiresApi(value = 26)
setInitialDelay(@NonNull Duration duration)

Sets an initial delay for the WorkRequest.

@NonNull OneTimeWorkRequest.Builder
setInitialDelay(long duration, @NonNull TimeUnit timeUnit)

Sets an initial delay for the WorkRequest.

final @NonNull OneTimeWorkRequest.Builder

Adds input Data to the work.

final @NonNull OneTimeWorkRequest.Builder

Specifies the name of the trace span to be used by WorkManager when executing the specified WorkRequest.

Public constructors

Builder

Added in 1.0.0
public Builder(@NonNull Class<@NonNull ListenableWorker> workerClass)
Parameters
@NonNull Class<@NonNull ListenableWorker> workerClass

The ListenableWorker class to run for this work

Builder

Added in 2.10.0
public Builder(@NonNull KClass<@NonNull ListenableWorker> workerClass)

Creates a builder for OneTimeWorkRequests.

Parameters
@NonNull KClass<@NonNull ListenableWorker> workerClass

The ListenableWorker class to run for this work

Public methods

setInputMerger

Added in 1.0.0
public final @NonNull OneTimeWorkRequest.Builder setInputMerger(@NonNull Class<@NonNull InputMerger> inputMerger)

Specifies the InputMerger class name for this OneTimeWorkRequest.

Before workers run, they receive input Data from their parent workers, as well as anything specified directly to them via WorkRequest.Builder.setInputData. An InputMerger takes all of these objects and converts them to a single merged Data to be used as the worker input. The default InputMerger is OverwritingInputMerger. This library also offers ArrayCreatingInputMerger; you can also specify your own.

Parameters
@NonNull Class<@NonNull InputMerger> inputMerger

The class name of the InputMerger for this OneTimeWorkRequest

Extension functions

OneTimeWorkRequestKt.setInputMerger

public final @NonNull OneTimeWorkRequest.Builder OneTimeWorkRequestKt.setInputMerger(
    @NonNull OneTimeWorkRequest.Builder receiver,
    @NonNull KClass<@NonNull InputMerger> inputMerger
)

Sets an InputMerger on the OneTimeWorkRequest.Builder.