Stay organized with collections Save and categorize content based on your preferences.

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

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

getDefaultProcessName

public @Nullable String getDefaultProcessName()
Returns
@Nullable String

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

getExecutor

public @NonNull Executor getExecutor()

Gets the Executor used by WorkManager to execute Workers.

Returns
@NonNull Executor

The Executor used by WorkManager to execute Workers

getInitializationExceptionHandler

public @Nullable Consumer<ThrowablegetInitializationExceptionHandler()
Returns
@Nullable Consumer<Throwable>

the < that is used to intercept exceptions caused when trying to initialize WorkManager.

getInputMergerFactory

public @NonNull InputMergerFactory getInputMergerFactory()
Returns
@NonNull InputMergerFactory

The InputMergerFactory used by WorkManager to create instances of InputMergers.

getMaxJobSchedulerId

public int getMaxJobSchedulerId()

Gets the last valid id when scheduling work with android.app.job.JobScheduler.

Returns
int

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 (getMinJobSchedulerId, getMaxJobSchedulerId), it is reset to (getMinJobSchedulerId).

getMinJobSchedulerId

public int getMinJobSchedulerId()

Gets the first valid id used when scheduling work with android.app.job.JobScheduler.

Returns
int

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 (getMinJobSchedulerId, getMaxJobSchedulerId), it is reset to (getMinJobSchedulerId).

getRunnableScheduler

public @NonNull RunnableScheduler getRunnableScheduler()
Returns
@NonNull RunnableScheduler

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

getSchedulingExceptionHandler

public @Nullable Consumer<ThrowablegetSchedulingExceptionHandler()
Returns
@Nullable Consumer<Throwable>

the SchedulingExceptionHandler that can be used to intercept exceptions caused when trying to schedule WorkRequests.

getTaskExecutor

public @NonNull Executor getTaskExecutor()

Gets the Executor used by WorkManager for all its internal business logic.

Returns
@NonNull Executor

The Executor used by WorkManager for all its internal business logic

getWorkerFactory

public @NonNull WorkerFactory getWorkerFactory()

Gets the WorkerFactory used by WorkManager to create ListenableWorkers.