Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

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 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

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