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.BuilderA Builder for |
public interface Configuration.ProviderA class that can provide the |
Constants |
|
|---|---|
static final int |
MIN_SCHEDULER_LIMIT = 20The minimum number of system requests which can be enqueued by |
Public methods |
|
|---|---|
final @NonNull Clock |
getClock()The |
final int |
Maximum number of Workers with |
final String |
The |
final @NonNull Executor |
The |
final Consumer<@NonNull Throwable> |
The exception handler that is used to intercept exceptions caused when trying to initialize |
final @NonNull InputMergerFactory |
The |
final int |
The last valid id (inclusive) used by |
final int |
The first valid id (inclusive) used by |
final long |
The time in milliseconds that the designated process stays active before unbinding when using |
final @NonNull RunnableScheduler |
The |
final Consumer<@NonNull Throwable> |
The exception handler that can be used to intercept exceptions caused when trying to schedule |
final @NonNull Executor |
The |
final @NonNull CoroutineContext |
The |
final Consumer<@NonNull WorkerExceptionInfo> |
The exception handler that can be used to intercept exceptions caused when trying to execute |
final @NonNull WorkerFactory |
The |
final Consumer<@NonNull WorkerExceptionInfo> |
The exception handler that can be used to intercept exceptions caused when trying to initialize |
final boolean |
Specifies whether WorkManager automatically set |
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
public final @NonNull Clock getClock()
The Clock used by WorkManager to calculate schedules and perform book-keeping.
getContentUriTriggerWorkersLimit
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
public final String getDefaultProcessName()
The String name of the process where work should be scheduled.
getExecutor
public final @NonNull Executor getExecutor()
The Executor used by WorkManager to execute Workers.
getInitializationExceptionHandler
public final Consumer<@NonNull Throwable> getInitializationExceptionHandler()
The exception handler that is used to intercept exceptions caused when trying to initialize WorkManager.
getInputMergerFactory
public final @NonNull InputMergerFactory getInputMergerFactory()
The InputMergerFactory used by WorkManager to create instances of InputMergers.
getMaxJobSchedulerId
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
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
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
public final @NonNull RunnableScheduler getRunnableScheduler()
The RunnableScheduler to keep track of timed work in the in-process scheduler.
getSchedulingExceptionHandler
public final Consumer<@NonNull Throwable> getSchedulingExceptionHandler()
The exception handler that can be used to intercept exceptions caused when trying to schedule WorkRequests.
getTaskExecutor
public final @NonNull Executor getTaskExecutor()
The Executor used by WorkManager for all its internal business logic
getWorkerCoroutineContext
public final @NonNull CoroutineContext getWorkerCoroutineContext()
The CoroutineContext used by WorkManager to execute CoroutineWorkers.
getWorkerExecutionExceptionHandler
public final Consumer<@NonNull WorkerExceptionInfo> getWorkerExecutionExceptionHandler()
The exception handler that can be used to intercept exceptions caused when trying to execute ListenableWorkers.
getWorkerFactory
public final @NonNull WorkerFactory getWorkerFactory()
The WorkerFactory used by WorkManager to create ListenableWorkers
getWorkerInitializationExceptionHandler
public final Consumer<@NonNull WorkerExceptionInfo> getWorkerInitializationExceptionHandler()
The exception handler that can be used to intercept exceptions caused when trying to initialize ListenableWorkers.
isMarkingJobsAsImportantWhileForeground
@ExperimentalConfigurationApi
public final boolean isMarkingJobsAsImportantWhileForeground()
Specifies whether WorkManager automatically set android.app.job.JobInfo.Builder.setImportantWhileForeground for workers that are eligible to run immediately.