Configuration

public final class Configuration


The Configuration object used to customize WorkManager upon initialization. Configuration contains various parameters used to setup WorkManager. For example, it is possible to customize the Executor used by Workers here.

To set a custom Configuration for WorkManager, see WorkManager.initialize.

Summary

Nested types

public final class Configuration.Builder

A Builder for Configurations.

public interface Configuration.Provider

A class that can provide the Configuration for WorkManager and allow for on-demand initialization of WorkManager.

Constants

static final int

The minimum number of system requests which can be enqueued by WorkManager when using android.app.job.JobScheduler or android.app.AlarmManager.

Public methods

final @NonNull Clock

The Clock used by WorkManager to calculate schedules and perform book-keeping.

final int

Maximum number of Workers with Constraints.contentUriTriggers that could be enqueued simultaneously.

final String

The String name of the process where work should be scheduled.

final @NonNull Executor

The Executor used by WorkManager to execute Workers.

final Consumer<@NonNull Throwable>

The exception handler that is used to intercept exceptions caused when trying to initialize WorkManager.

final @NonNull InputMergerFactory

The InputMergerFactory used by WorkManager to create instances of InputMergers.

final int

The last valid id (inclusive) used by WorkManager when creating new instances of android.app.job.JobInfos.

final int

The first valid id (inclusive) used by WorkManager when creating new instances of android.app.job.JobInfos.

final @NonNull RunnableScheduler

The RunnableScheduler to keep track of timed work in the in-process scheduler.

final Consumer<@NonNull Throwable>

The exception handler that can be used to intercept exceptions caused when trying to schedule WorkRequests.

final @NonNull Executor

The Executor used by WorkManager for all its internal business logic

final @NonNull WorkerFactory

The WorkerFactory used by WorkManager to create ListenableWorkers

Constants

MIN_SCHEDULER_LIMIT

public static final int MIN_SCHEDULER_LIMIT = 20

The minimum number of system requests which can be enqueued by WorkManager when using android.app.job.JobScheduler or android.app.AlarmManager.

Public methods

getClock

Added in 2.9.0
public final @NonNull Clock getClock()

The Clock used by WorkManager to calculate schedules and perform book-keeping.

getContentUriTriggerWorkersLimit

Added in 2.9.0
public final int getContentUriTriggerWorkersLimit()

Maximum number of Workers with Constraints.contentUriTriggers that could be enqueued simultaneously.

Unlike the other workers Workers with Constraints.contentUriTriggers must immediately occupy slots in JobScheduler to avoid missing updates, thus they are separated in the its own category.

getDefaultProcessName

Added in 2.5.0
public final String getDefaultProcessName()

The String name of the process where work should be scheduled.

getExecutor

Added in 1.0.0
public final @NonNull Executor getExecutor()

The Executor used by WorkManager to execute Workers.

getInitializationExceptionHandler

Added in 2.8.0
public final Consumer<@NonNull ThrowablegetInitializationExceptionHandler()

The exception handler that is used to intercept exceptions caused when trying to initialize WorkManager.

getInputMergerFactory

Added in 2.3.0
public final @NonNull InputMergerFactory getInputMergerFactory()

The InputMergerFactory used by WorkManager to create instances of InputMergers.

getMaxJobSchedulerId

Added in 1.0.0
public final int getMaxJobSchedulerId()

The last valid id (inclusive) used by WorkManager when creating new instances of android.app.job.JobInfos.

If the current jobId goes beyond the bounds of the defined range of (Configuration.minJobSchedulerId, Configuration.maxJobSchedulerId), it is reset to (Configuration.minJobSchedulerId).

getMinJobSchedulerId

Added in 1.0.0
public final int getMinJobSchedulerId()

The first valid id (inclusive) used by WorkManager when creating new instances of android.app.job.JobInfos.

If the current jobId goes beyond the bounds of the defined range of (Configuration.minJobSchedulerId, Configuration.maxJobSchedulerId), it is reset to (Configuration.minJobSchedulerId).

getRunnableScheduler

Added in 2.4.0
public final @NonNull RunnableScheduler getRunnableScheduler()

The RunnableScheduler to keep track of timed work in the in-process scheduler.

getSchedulingExceptionHandler

Added in 2.8.0
public final Consumer<@NonNull ThrowablegetSchedulingExceptionHandler()

The exception handler that can be used to intercept exceptions caused when trying to schedule WorkRequests.

getTaskExecutor

Added in 2.1.0
public final @NonNull Executor getTaskExecutor()

The Executor used by WorkManager for all its internal business logic

getWorkerFactory

Added in 1.0.0
public final @NonNull WorkerFactory getWorkerFactory()

The WorkerFactory used by WorkManager to create ListenableWorkers