OneTimeWorkRequest.Builder

public static final class OneTimeWorkRequest.Builder
extends Builder<OneTimeWorkRequest.BuilderOneTimeWorkRequest>

java.lang.Object
   ↳ androidx.work.WorkRequest.Builder<androidx.work.OneTimeWorkRequest.Builderandroidx.work.OneTimeWorkRequest>
     ↳ androidx.work.OneTimeWorkRequest.Builder


Builder for OneTimeWorkRequests.

Summary

Public constructors

OneTimeWorkRequest.Builder(Class<? extends ListenableWorker> workerClass)

Creates a OneTimeWorkRequest.

Public methods

OneTimeWorkRequest.Builder setInitialDelay(Duration duration)

Sets an initial delay for the OneTimeWorkRequest.

OneTimeWorkRequest.Builder setInitialDelay(long duration, TimeUnit timeUnit)

Sets an initial delay for the OneTimeWorkRequest.

OneTimeWorkRequest.Builder setInputMerger(Class<? extends InputMerger> inputMerger)

Specifies the InputMerger class name for this OneTimeWorkRequest.

Inherited methods

Public constructors

OneTimeWorkRequest.Builder

public OneTimeWorkRequest.Builder (Class<? extends ListenableWorker> workerClass)

Creates a OneTimeWorkRequest.

Parameters
workerClass Class: The ListenableWorker class to run for this work

Public methods

setInitialDelay

public OneTimeWorkRequest.Builder setInitialDelay (Duration duration)

Sets an initial delay for the OneTimeWorkRequest.

Parameters
duration Duration: The length of the delay

Returns
OneTimeWorkRequest.Builder The current OneTimeWorkRequest.Builder

setInitialDelay

public OneTimeWorkRequest.Builder setInitialDelay (long duration, 
                TimeUnit timeUnit)

Sets an initial delay for the OneTimeWorkRequest.

Parameters
duration long: The length of the delay in timeUnit units

timeUnit TimeUnit: The units of time for duration

Returns
OneTimeWorkRequest.Builder The current OneTimeWorkRequest.Builder

setInputMerger

public OneTimeWorkRequest.Builder setInputMerger (Class<? extends 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(Data). 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
inputMerger Class: The class name of the InputMerger for this OneTimeWorkRequest

Returns
OneTimeWorkRequest.Builder The current OneTimeWorkRequest.Builder