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

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.

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 ClockgetClock()

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 StringgetDefaultProcessName()

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

getExecutor

Added in 1.0.0
public final @NonNull ExecutorgetExecutor()

The Executor used by WorkManager to execute Workers.

getInitializationExceptionHandler

Added in 2.8.0
public final Consumer<@NonNull Throwable> getInitializationExceptionHandler()

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

getInputMergerFactory

Added in 2.3.0
public final @NonNull InputMergerFactorygetInputMergerFactory()

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

getRemoteSessionTimeoutMillis

Added in 2.11.2
public final long getRemoteSessionTimeoutMillis()

The time in milliseconds that the designated process stays active before unbinding when using androidx.work.multiprocess.RemoteWorkManager.

The default timeout is androidx.work.multiprocess.RemoteWorkManager.DEFAULT_SESSION_TIMEOUT_MILLIS.

getRunnableScheduler

Added in 2.4.0
public final @NonNull RunnableSchedulergetRunnableScheduler()

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

getSchedulingExceptionHandler

Added in 2.8.0
public final Consumer<@NonNull Throwable> getSchedulingExceptionHandler()

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 ExecutorgetTaskExecutor()

The Executor used by WorkManager for all its internal business logic

getWorkerCoroutineContext

Added in 2.10.0
public final @NonNull CoroutineContextgetWorkerCoroutineContext()

The CoroutineContext used by WorkManager to execute CoroutineWorkers.

getWorkerExecutionExceptionHandler

Added in 2.10.0
public final Consumer<@NonNull WorkerExceptionInfo> getWorkerExecutionExceptionHandler()

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 WorkerFactorygetWorkerFactory()

The WorkerFactory used by WorkManager to create ListenableWorkers

getWorkerInitializationExceptionHandler

Added in 2.10.0
public final Consumer<@NonNull WorkerExceptionInfo> getWorkerInitializationExceptionHandler()

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.