WorkRequest.Builder

public static abstract class WorkRequest.Builder
extends Object

java.lang.Object
   ↳ androidx.work.WorkRequest.Builder<B extends androidx.work.WorkRequest.Builder<?, ?>, W extends androidx.work.WorkRequest>


A builder for WorkRequests. There are two concrete implementations of this class: OneTimeWorkRequest.Builder and PeriodicWorkRequest.Builder.

Summary

Public methods

final B addTag(String tag)

Adds a tag for the work.

final W build()

Builds a WorkRequest based on this WorkRequest.Builder.

final B keepResultsForAtLeast(long duration, TimeUnit timeUnit)

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

final B keepResultsForAtLeast(Duration duration)

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

final B setBackoffCriteria(BackoffPolicy backoffPolicy, long backoffDelay, TimeUnit timeUnit)

Sets the backoff policy and backoff delay for the work.

final B setBackoffCriteria(BackoffPolicy backoffPolicy, Duration duration)

Sets the backoff policy and backoff delay for the work.

final B setConstraints(Constraints constraints)

Adds constraints to the WorkRequest.

B setExpedited(OutOfQuotaPolicy policy)

Marks the WorkRequest as important to the user.

B setInitialDelay(Duration duration)

Sets an initial delay for the WorkRequest.

B setInitialDelay(long duration, TimeUnit timeUnit)

Sets an initial delay for the WorkRequest.