# Configuration

Artifact: [androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work) [View Source](https://cs.android.com/search?q=file:androidx/work/Configuration.kt+class:androidx.work.Configuration) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

*** ** * ** ***


```
public final class Configuration
```

<br />

*** ** * ** ***

The Configuration object used to customize `https://developer.android.com/reference/androidx/work/WorkManager` upon initialization. Configuration contains various parameters used to setup WorkManager. For example, it is possible to customize the `https://developer.android.com/reference/java/util/concurrent/Executor.html` used by `https://developer.android.com/reference/androidx/work/Worker`s here.

To set a custom Configuration for WorkManager, see `https://developer.android.com/reference/androidx/work/WorkManager#initialize(android.content.Context,androidx.work.Configuration)`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/work/Configuration.Builder` A Builder for `https://developer.android.com/reference/androidx/work/Configuration`s. |
| `public interface https://developer.android.com/reference/androidx/work/Configuration.Provider` A class that can provide the `https://developer.android.com/reference/androidx/work/Configuration` for WorkManager and allow for on-demand initialization of WorkManager. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/work/Configuration#MIN_SCHEDULER_LIMIT() = 20` The minimum number of system requests which can be enqueued by `https://developer.android.com/reference/androidx/work/WorkManager` when using `https://developer.android.com/reference/android/app/job/JobScheduler.html` or `https://developer.android.com/reference/android/app/AlarmManager.html`. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Clock` | `https://developer.android.com/reference/androidx/work/Configuration#getClock()()` The `https://developer.android.com/reference/androidx/work/Clock` used by `https://developer.android.com/reference/androidx/work/WorkManager` to calculate schedules and perform book-keeping. |
| `final int` | `https://developer.android.com/reference/androidx/work/Configuration#getContentUriTriggerWorkersLimit()()` Maximum number of Workers with `https://developer.android.com/reference/androidx/work/Constraints#contentUriTriggers()` that could be enqueued simultaneously. |
| `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/work/Configuration#getDefaultProcessName()()` The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` name of the process where work should be scheduled. |
| `final https://developer.android.com/reference/androidx/work/ExecutionEventListener` | `@https://developer.android.com/reference/androidx/work/ExperimentalEventsApi https://developer.android.com/reference/androidx/work/Configuration#getExecutionEventListener()()` The `https://developer.android.com/reference/androidx/work/ExecutionEventListener` that listens to work execution events for all workers. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/androidx/work/Configuration#getExecutor()()` The `https://developer.android.com/reference/java/util/concurrent/Executor.html` used by `https://developer.android.com/reference/androidx/work/WorkManager` to execute `https://developer.android.com/reference/androidx/work/Worker`s. |
| `final https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html>` | `https://developer.android.com/reference/androidx/work/Configuration#getInitializationExceptionHandler()()` The exception handler that is used to intercept exceptions caused when trying to initialize `https://developer.android.com/reference/androidx/work/WorkManager`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/InputMergerFactory` | `https://developer.android.com/reference/androidx/work/Configuration#getInputMergerFactory()()` The `https://developer.android.com/reference/androidx/work/InputMergerFactory` used by `https://developer.android.com/reference/androidx/work/WorkManager` to create instances of `https://developer.android.com/reference/androidx/work/InputMerger`s. |
| `final int` | `https://developer.android.com/reference/androidx/work/Configuration#getMaxJobSchedulerId()()` The last valid id (inclusive) used by `https://developer.android.com/reference/androidx/work/WorkManager` when creating new instances of `https://developer.android.com/reference/android/app/job/JobInfo.html`s. |
| `final int` | `https://developer.android.com/reference/androidx/work/Configuration#getMinJobSchedulerId()()` The first valid id (inclusive) used by `https://developer.android.com/reference/androidx/work/WorkManager` when creating new instances of `https://developer.android.com/reference/android/app/job/JobInfo.html`s. |
| `final long` | `https://developer.android.com/reference/androidx/work/Configuration#getRemoteSessionTimeoutMillis()()` The time in milliseconds that the designated process stays active before unbinding when using `https://developer.android.com/reference/androidx/work/multiprocess/RemoteWorkManager`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/RunnableScheduler` | `https://developer.android.com/reference/androidx/work/Configuration#getRunnableScheduler()()` The `https://developer.android.com/reference/androidx/work/RunnableScheduler` to keep track of timed work in the in-process scheduler. |
| `final https://developer.android.com/reference/androidx/work/ScheduleEventListener` | `@https://developer.android.com/reference/androidx/work/ExperimentalEventsApi https://developer.android.com/reference/androidx/work/Configuration#getScheduleEventListener()()` The `https://developer.android.com/reference/androidx/work/ScheduleEventListener` that listens to work execution events for all workers. |
| `final https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html>` | `https://developer.android.com/reference/androidx/work/Configuration#getSchedulingExceptionHandler()()` The exception handler that can be used to intercept exceptions caused when trying to schedule `https://developer.android.com/reference/androidx/work/WorkRequest`s. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/androidx/work/Configuration#getTaskExecutor()()` The `https://developer.android.com/reference/java/util/concurrent/Executor.html` used by `https://developer.android.com/reference/androidx/work/WorkManager` for all its internal business logic |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` | `https://developer.android.com/reference/androidx/work/Configuration#getWorkerCoroutineContext()()` The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used by `https://developer.android.com/reference/androidx/work/WorkManager` to execute `https://developer.android.com/reference/androidx/work/CoroutineWorker`s. |
| `final https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerExceptionInfo>` | `https://developer.android.com/reference/androidx/work/Configuration#getWorkerExecutionExceptionHandler()()` The exception handler that can be used to intercept exceptions caused when trying to execute `https://developer.android.com/reference/androidx/work/ListenableWorker`s. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerFactory` | `https://developer.android.com/reference/androidx/work/Configuration#getWorkerFactory()()` The `https://developer.android.com/reference/androidx/work/WorkerFactory` used by `https://developer.android.com/reference/androidx/work/WorkManager` to create `https://developer.android.com/reference/androidx/work/ListenableWorker`s |
| `final https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerExceptionInfo>` | `https://developer.android.com/reference/androidx/work/Configuration#getWorkerInitializationExceptionHandler()()` The exception handler that can be used to intercept exceptions caused when trying to initialize `https://developer.android.com/reference/androidx/work/ListenableWorker`s. |
| `final boolean` | `@https://developer.android.com/reference/androidx/work/ExperimentalConfigurationApi https://developer.android.com/reference/androidx/work/Configuration#isGreedySchedulerEnabled()()` Specifies whether the in-process opportunistic greedy scheduler is enabled |
| `final boolean` | `@https://developer.android.com/reference/androidx/work/ExperimentalConfigurationApi https://developer.android.com/reference/androidx/work/Configuration#isMarkingJobsAsImportantWhileForeground()()` Specifies whether WorkManager automatically set `https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#setImportantWhileForeground(boolean)` 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 `https://developer.android.com/reference/androidx/work/WorkManager` when using `https://developer.android.com/reference/android/app/job/JobScheduler.html` or `https://developer.android.com/reference/android/app/AlarmManager.html`.

## Public methods

### getClock

Added in [2.9.0](https://developer.android.com/jetpack/androidx/releases/work#2.9.0)

```
public final @NonNull Clock getClock()
```

The `https://developer.android.com/reference/androidx/work/Clock` used by `https://developer.android.com/reference/androidx/work/WorkManager` to calculate schedules and perform book-keeping.

### getContentUriTriggerWorkersLimit

Added in [2.9.0](https://developer.android.com/jetpack/androidx/releases/work#2.9.0)

```
public final int getContentUriTriggerWorkersLimit()
```

Maximum number of Workers with `https://developer.android.com/reference/androidx/work/Constraints#contentUriTriggers()` that could be enqueued simultaneously.

Unlike the other workers Workers with `https://developer.android.com/reference/androidx/work/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](https://developer.android.com/jetpack/androidx/releases/work#2.5.0)

```
public final String getDefaultProcessName()
```

The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` name of the process where work should be scheduled.

### getExecutionEventListener

Added in [2.12.0](https://developer.android.com/jetpack/androidx/releases/work#2.12.0)

```
@ExperimentalEventsApi
public final ExecutionEventListener getExecutionEventListener()
```

The `https://developer.android.com/reference/androidx/work/ExecutionEventListener` that listens to work execution events for all workers.

### getExecutor

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public final @NonNull Executor getExecutor()
```

The `https://developer.android.com/reference/java/util/concurrent/Executor.html` used by `https://developer.android.com/reference/androidx/work/WorkManager` to execute `https://developer.android.com/reference/androidx/work/Worker`s.

### getInitializationExceptionHandler

Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/work#2.8.0)

```
public final Consumer<@NonNull Throwable> getInitializationExceptionHandler()
```

The exception handler that is used to intercept exceptions caused when trying to initialize `https://developer.android.com/reference/androidx/work/WorkManager`.

### getInputMergerFactory

Added in [2.3.0](https://developer.android.com/jetpack/androidx/releases/work#2.3.0)

```
public final @NonNull InputMergerFactory getInputMergerFactory()
```

The `https://developer.android.com/reference/androidx/work/InputMergerFactory` used by `https://developer.android.com/reference/androidx/work/WorkManager` to create instances of `https://developer.android.com/reference/androidx/work/InputMerger`s.

### getMaxJobSchedulerId

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public final int getMaxJobSchedulerId()
```

The last valid id (inclusive) used by `https://developer.android.com/reference/androidx/work/WorkManager` when creating new instances of `https://developer.android.com/reference/android/app/job/JobInfo.html`s.

If the current `jobId` goes beyond the bounds of the defined range of (`https://developer.android.com/reference/androidx/work/Configuration#minJobSchedulerId()`, `https://developer.android.com/reference/androidx/work/Configuration#maxJobSchedulerId()`), it is reset to (`https://developer.android.com/reference/androidx/work/Configuration#minJobSchedulerId()`).

### getMinJobSchedulerId

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public final int getMinJobSchedulerId()
```

The first valid id (inclusive) used by `https://developer.android.com/reference/androidx/work/WorkManager` when creating new instances of `https://developer.android.com/reference/android/app/job/JobInfo.html`s.

If the current `jobId` goes beyond the bounds of the defined range of (`https://developer.android.com/reference/androidx/work/Configuration#minJobSchedulerId()`, `https://developer.android.com/reference/androidx/work/Configuration#maxJobSchedulerId()`), it is reset to (`https://developer.android.com/reference/androidx/work/Configuration#minJobSchedulerId()`).

### getRemoteSessionTimeoutMillis

Added in [2.11.0](https://developer.android.com/jetpack/androidx/releases/work#2.11.0)

```
public final long getRemoteSessionTimeoutMillis()
```

The time in milliseconds that the designated process stays active before unbinding when using `https://developer.android.com/reference/androidx/work/multiprocess/RemoteWorkManager`.

The default timeout is `https://developer.android.com/reference/androidx/work/multiprocess/RemoteWorkManager#DEFAULT_SESSION_TIMEOUT_MILLIS()`.

### getRunnableScheduler

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/work#2.4.0)

```
public final @NonNull RunnableScheduler getRunnableScheduler()
```

The `https://developer.android.com/reference/androidx/work/RunnableScheduler` to keep track of timed work in the in-process scheduler.

### getScheduleEventListener

Added in [2.12.0](https://developer.android.com/jetpack/androidx/releases/work#2.12.0)

```
@ExperimentalEventsApi
public final ScheduleEventListener getScheduleEventListener()
```

The `https://developer.android.com/reference/androidx/work/ScheduleEventListener` that listens to work execution events for all workers.

### getSchedulingExceptionHandler

Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/work#2.8.0)

```
public final Consumer<@NonNull Throwable> getSchedulingExceptionHandler()
```

The exception handler that can be used to intercept exceptions caused when trying to schedule `https://developer.android.com/reference/androidx/work/WorkRequest`s.

### getTaskExecutor

Added in [2.1.0](https://developer.android.com/jetpack/androidx/releases/work#2.1.0)

```
public final @NonNull Executor getTaskExecutor()
```

The `https://developer.android.com/reference/java/util/concurrent/Executor.html` used by `https://developer.android.com/reference/androidx/work/WorkManager` for all its internal business logic

### getWorkerCoroutineContext

Added in [2.10.0](https://developer.android.com/jetpack/androidx/releases/work#2.10.0)

```
public final @NonNull CoroutineContext getWorkerCoroutineContext()
```

The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` used by `https://developer.android.com/reference/androidx/work/WorkManager` to execute `https://developer.android.com/reference/androidx/work/CoroutineWorker`s.

### getWorkerExecutionExceptionHandler

Added in [2.10.0](https://developer.android.com/jetpack/androidx/releases/work#2.10.0)

```
public final Consumer<@NonNull WorkerExceptionInfo> getWorkerExecutionExceptionHandler()
```

The exception handler that can be used to intercept exceptions caused when trying to execute `https://developer.android.com/reference/androidx/work/ListenableWorker`s.

### getWorkerFactory

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public final @NonNull WorkerFactory getWorkerFactory()
```

The `https://developer.android.com/reference/androidx/work/WorkerFactory` used by `https://developer.android.com/reference/androidx/work/WorkManager` to create `https://developer.android.com/reference/androidx/work/ListenableWorker`s

### getWorkerInitializationExceptionHandler

Added in [2.10.0](https://developer.android.com/jetpack/androidx/releases/work#2.10.0)

```
public final Consumer<@NonNull WorkerExceptionInfo> getWorkerInitializationExceptionHandler()
```

The exception handler that can be used to intercept exceptions caused when trying to initialize `https://developer.android.com/reference/androidx/work/ListenableWorker`s.

### isGreedySchedulerEnabled

Added in [2.12.0](https://developer.android.com/jetpack/androidx/releases/work#2.12.0)

```
@ExperimentalConfigurationApi
public final boolean isGreedySchedulerEnabled()
```

Specifies whether the in-process opportunistic greedy scheduler is enabled

This is enabled by default and should only be disabled for experimental purposes.

### isMarkingJobsAsImportantWhileForeground

Added in [2.10.0](https://developer.android.com/jetpack/androidx/releases/work#2.10.0)

```
@ExperimentalConfigurationApi
public final boolean isMarkingJobsAsImportantWhileForeground()
```

Specifies whether WorkManager automatically set `https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#setImportantWhileForeground(boolean)` for workers that are eligible to run immediately.