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 CoroutineContext

The CoroutineContext used by WorkManager to execute CoroutineWorkers.

final Consumer<@NonNull WorkerExceptionInfo>

The exception handler that can be used to intercept exceptions caused when trying to execute ListenableWorkers.

final @NonNull WorkerFactory

The WorkerFactory used by WorkManager to create ListenableWorkers

final Consumer<@NonNull WorkerExceptionInfo>

The exception handler that can be used to intercept exceptions caused when trying to initialize ListenableWorkers.

final boolean

Specifies whether WorkManager automatically set android.app.job.JobInfo.Builder.setImportantWhileForeground for workers that are eligible to run immediately.

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

getWorkerCoroutineContext

Added in 2.10.0
public final @NonNull CoroutineContext getWorkerCoroutineContext()

The CoroutineContext used by WorkManager to execute CoroutineWorkers.

getWorkerExecutionExceptionHandler

Added in 2.10.0
public final Consumer<@NonNull WorkerExceptionInfogetWorkerExecutionExceptionHandler()

The exception handler that can be used to intercept exceptions caused when trying to execute ListenableWorkers.

getWorkerFactory

Added in 1.0.0
public final @NonNull WorkerFactory getWorkerFactory()

The WorkerFactory used by WorkManager to create ListenableWorkers

getWorkerInitializationExceptionHandler

Added in 2.10.0
public final Consumer<@NonNull WorkerExceptionInfogetWorkerInitializationExceptionHandler()

The exception handler that can be used to intercept exceptions caused when trying to initialize ListenableWorkers.

isMarkingJobsAsImportantWhileForeground

Added in 2.10.0
@ExperimentalConfigurationApi
public final boolean isMarkingJobsAsImportantWhileForeground()

Specifies whether WorkManager automatically set android.app.job.JobInfo.Builder.setImportantWhileForeground for workers that are eligible to run immediately.