OneTimeWorkRequest.Builder

class OneTimeWorkRequest.Builder : WorkRequest.Builder


Builder for OneTimeWorkRequests.

Summary

Public constructors

Public functions

OneTimeWorkRequest.Builder

Specifies the InputMerger class name for this OneTimeWorkRequest.

Inherited functions

From androidx.work.WorkRequest.Builder
OneTimeWorkRequest.Builder
addTag(tag: String)

Adds a tag for the work.

OneTimeWorkRequest

Builds a WorkRequest based on this Builder.

OneTimeWorkRequest.Builder
@RequiresApi(value = 26)
keepResultsForAtLeast(duration: Duration)

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

OneTimeWorkRequest.Builder
keepResultsForAtLeast(duration: Long, timeUnit: TimeUnit)

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

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

Sets the backoff policy and backoff delay for the work.

OneTimeWorkRequest.Builder
setBackoffCriteria(
    backoffPolicy: BackoffPolicy,
    backoffDelay: Long,
    timeUnit: TimeUnit
)

Sets the backoff policy and backoff delay for the work.

OneTimeWorkRequest.Builder

Adds constraints to the WorkRequest.

open OneTimeWorkRequest.Builder

Marks the WorkRequest as important to the user.

OneTimeWorkRequest.Builder
setId(id: UUID)

The id of the request.

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

Sets an initial delay for the WorkRequest.

open OneTimeWorkRequest.Builder
setInitialDelay(duration: Long, timeUnit: TimeUnit)

Sets an initial delay for the WorkRequest.

OneTimeWorkRequest.Builder
setInputData(inputData: Data)

Adds input Data to the work.

Public constructors

Builder

Added in 1.0.0
Builder(workerClass: Class<ListenableWorker>)
Parameters
workerClass: Class<ListenableWorker>

The ListenableWorker class to run for this work

Public functions

setInputMerger

Added in 1.0.0
fun setInputMerger(inputMerger: Class<InputMerger>): OneTimeWorkRequest.Builder

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
inputMerger: Class<InputMerger>

The class name of the InputMerger for this OneTimeWorkRequest

Returns
OneTimeWorkRequest.Builder

The current Builder

Extension functions