lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

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 OneTimeWorkRequest class.

Summary

Public constructors

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

Public methods

OneTimeWorkRequest build()

Builds this work object.

OneTimeWorkRequest.Builder setInitialDelay(Duration duration)

Add an initial delay to the OneTimeWorkRequest.

OneTimeWorkRequest.Builder setInitialDelay(long duration, TimeUnit timeUnit)

Add an initial delay to the OneTimeWorkRequest.

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

Specify the InputMerger class name for this OneTimeWorkRequest.

Inherited methods

Public constructors

OneTimeWorkRequest.Builder

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

Parameters
workerClass Class

Public methods

build

public OneTimeWorkRequest build ()

Builds this work object.

Returns
OneTimeWorkRequest The concrete implementation of the work associated with this builder

setInitialDelay

public OneTimeWorkRequest.Builder setInitialDelay (Duration duration)

Add an initial delay to 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)

Add an initial delay to 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)

Specify the InputMerger class name for this OneTimeWorkRequest. An InputMerger takes one or more Data inputs to a Worker and converts them to a single merged Data to be used as its input. The default InputMerger is OverwritingInputMerger.

Parameters
inputMerger Class: The class name of the InputMerger for this OneTimeWorkRequest

Returns
OneTimeWorkRequest.Builder The current OneTimeWorkRequest.Builder