# Configuration.Builder

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.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

*** ** * ** ***


```
public final class Configuration.Builder
```

<br />

*** ** * ** ***

A Builder for `https://developer.android.com/reference/androidx/work/Configuration`s.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/work/Configuration.Builder#Builder()()` Creates a new `https://developer.android.com/reference/androidx/work/Configuration.Builder`. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#build()()` Builds a `https://developer.android.com/reference/androidx/work/Configuration` object. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setClock(androidx.work.Clock)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Clock clock)` Sets a `https://developer.android.com/reference/androidx/work/Clock` for WorkManager to calculate schedules and perform book-keeping. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setContentUriTriggerWorkersLimit(kotlin.Int)(int contentUriTriggerWorkersLimit)` Specifies the 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/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setDefaultProcessName(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html processName)` Designates the primary process that `https://developer.android.com/reference/androidx/work/WorkManager` should schedule work in. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `@https://developer.android.com/reference/androidx/work/ExperimentalEventsApi https://developer.android.com/reference/androidx/work/Configuration.Builder#setExecutionEventListener(androidx.work.ExecutionEventListener)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ExecutionEventListener listener)` Set a `https://developer.android.com/reference/androidx/work/ExecutionEventListener` to run whenever work execution events occur for any worker. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setExecutor(java.util.concurrent.Executor)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor)` Specifies a custom `https://developer.android.com/reference/java/util/concurrent/Executor.html` to run `https://developer.android.com/reference/androidx/work/Worker#doWork()`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `@https://developer.android.com/reference/androidx/work/ExperimentalConfigurationApi https://developer.android.com/reference/androidx/work/Configuration.Builder#setGreedySchedulerEnabled(kotlin.Boolean)(boolean enabled)` Specifies whether the in-process opportunistic greedy scheduler should be enabled. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setInitializationExceptionHandler(androidx.core.util.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull 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> exceptionHandler )` Specifies a `Consumer<Throwable>` that can be used to intercept exceptions caused when trying to initialize {@link WorkManager}, that usually happens when WorkManager cannot access its internal datastore. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setInputMergerFactory(androidx.work.InputMergerFactory)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/InputMergerFactory inputMergerFactory)` Specifies a custom `https://developer.android.com/reference/androidx/work/InputMergerFactory` for WorkManager. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setJobSchedulerJobIdRange(kotlin.Int,kotlin.Int)(int minJobSchedulerId, int maxJobSchedulerId)` Specifies the range of `https://developer.android.com/reference/android/app/job/JobInfo.html` IDs that can be used by `https://developer.android.com/reference/androidx/work/WorkManager`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `@https://developer.android.com/reference/androidx/work/ExperimentalConfigurationApi https://developer.android.com/reference/androidx/work/Configuration.Builder#setMarkingJobsAsImportantWhileForeground(kotlin.Boolean)(boolean markAsImportant)` Regulates whether WorkManager should automatically set `https://developer.android.com/reference/android/app/job/JobInfo.Builder.html#setImportantWhileForeground(boolean)` for workers that are eligible to run immediately. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setMaxSchedulerLimit(kotlin.Int)(int maxSchedulerLimit)` Specifies the maximum number of system requests made 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`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setMinimumLoggingLevel(kotlin.Int)(int loggingLevel)` Specifies the minimum logging level, corresponding to the constants found in `https://developer.android.com/reference/android/util/Log.html`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setRemoteSessionTimeoutMillis(kotlin.Long)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0, to = 1200000) long timeoutMillis )` Set how long in milliseconds that a `https://developer.android.com/reference/androidx/work/multiprocess/RemoteWorkManager` binding to the designated process stays active before timing out and unbinding. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setRunnableScheduler(androidx.work.RunnableScheduler)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/RunnableScheduler runnableScheduler)` Specifies the `https://developer.android.com/reference/androidx/work/RunnableScheduler` to be used by `https://developer.android.com/reference/androidx/work/WorkManager`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `@https://developer.android.com/reference/androidx/work/ExperimentalEventsApi https://developer.android.com/reference/androidx/work/Configuration.Builder#setScheduleEventListener(androidx.work.ScheduleEventListener)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ScheduleEventListener listener)` Set a `https://developer.android.com/reference/androidx/work/ScheduleEventListener` to run whenever work scheduling events occur for any worker. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setSchedulingExceptionHandler(androidx.core.util.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull 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> schedulingExceptionHandler )` Specifies a `Consumer<Throwable>` 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/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setTaskExecutor(java.util.concurrent.Executor)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html taskExecutor)` Specifies a `https://developer.android.com/reference/java/util/concurrent/Executor.html` which will be used by WorkManager for all its internal book-keeping. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setWorkerCoroutineContext(kotlin.coroutines.CoroutineContext)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html context)` Specifies a custom `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` to run `https://developer.android.com/reference/androidx/work/CoroutineWorker#doWork()`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setWorkerExecutionExceptionHandler(androidx.core.util.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull 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> workerExceptionHandler )` Specifies a `WorkerExceptionHandler` 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/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setWorkerFactory(androidx.work.WorkerFactory)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerFactory workerFactory)` Specifies a custom `https://developer.android.com/reference/androidx/work/WorkerFactory` for WorkManager. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | `https://developer.android.com/reference/androidx/work/Configuration.Builder#setWorkerInitializationExceptionHandler(androidx.core.util.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull 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> workerExceptionHandler )` Specifies a `WorkerExceptionHandler` that can be used to intercept exceptions caused when trying to initialize `https://developer.android.com/reference/androidx/work/ListenableWorker`s. |

## Public constructors

### Builder

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

```
public Builder()
```

Creates a new `https://developer.android.com/reference/androidx/work/Configuration.Builder`.

## Public methods

### build

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

```
public final @NonNull Configuration build()
```

Builds a `https://developer.android.com/reference/androidx/work/Configuration` object.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration` | A `https://developer.android.com/reference/androidx/work/Configuration` object with this `https://developer.android.com/reference/androidx/work/Configuration.Builder`'s parameters. |

### setClock

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

```
public final @NonNull Configuration.Builder setClock(@NonNull Clock clock)
```

Sets a `https://developer.android.com/reference/androidx/work/Clock` for WorkManager to calculate schedules and perform book-keeping.

This should only be overridden for testing. It must return the same value as `https://developer.android.com/reference/java/lang/System.html#currentTimeMillis()` in production code.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Clock clock` | The `https://developer.android.com/reference/androidx/work/Clock` to use |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setContentUriTriggerWorkersLimit

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

```
public final @NonNull Configuration.Builder setContentUriTriggerWorkersLimit(int contentUriTriggerWorkersLimit)
```

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

### setDefaultProcessName

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

```
public final @NonNull Configuration.Builder setDefaultProcessName(@NonNull String processName)
```

Designates the primary process that `https://developer.android.com/reference/androidx/work/WorkManager` should schedule work in.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html processName` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` process name. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setExecutionEventListener

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

```
@ExperimentalEventsApi
public final @NonNull Configuration.Builder setExecutionEventListener(@NonNull ExecutionEventListener listener)
```

Set a `https://developer.android.com/reference/androidx/work/ExecutionEventListener` to run whenever work execution events occur for any worker.

These callbacks will be invoked on a thread bound to `https://developer.android.com/reference/androidx/work/Configuration#taskExecutor()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ExecutionEventListener listener` | `https://developer.android.com/reference/androidx/work/ExecutionEventListener` to set |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setExecutor

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

```
public final @NonNull Configuration.Builder setExecutor(@NonNull Executor executor)
```

Specifies a custom `https://developer.android.com/reference/java/util/concurrent/Executor.html` to run `https://developer.android.com/reference/androidx/work/Worker#doWork()`.

If `https://developer.android.com/reference/androidx/work/Configuration.Builder#setWorkerCoroutineContext(kotlin.coroutines.CoroutineContext)` wasn't called then the `https://developer.android.com/reference/androidx/work/Configuration.Builder#setExecutor(java.util.concurrent.Executor)` will be used as `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to run `https://developer.android.com/reference/androidx/work/CoroutineWorker` as well.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | An `https://developer.android.com/reference/java/util/concurrent/Executor.html` for running `https://developer.android.com/reference/androidx/work/Worker`s |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setGreedySchedulerEnabled

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

```
@ExperimentalConfigurationApi
public final @NonNull Configuration.Builder setGreedySchedulerEnabled(boolean enabled)
```

Specifies whether the in-process opportunistic greedy scheduler should be enabled.

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

| Parameters |
|---|---|
| `boolean enabled` | whether to enable the greedy scheduler |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setInitializationExceptionHandler

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

```
public final @NonNull Configuration.Builder setInitializationExceptionHandler(
    @NonNull Consumer<@NonNull Throwable> exceptionHandler
)
```

Specifies a `Consumer<Throwable>` that can be used to intercept exceptions caused when trying to initialize {@link WorkManager}, that usually happens when WorkManager cannot access its internal datastore.

This exception handler will be invoked on a thread bound to `https://developer.android.com/reference/androidx/work/Configuration#taskExecutor()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull 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> exceptionHandler` | an instance to handle exceptions |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setInputMergerFactory

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

```
public final @NonNull Configuration.Builder setInputMergerFactory(@NonNull InputMergerFactory inputMergerFactory)
```

Specifies a custom `https://developer.android.com/reference/androidx/work/InputMergerFactory` for WorkManager.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/InputMergerFactory inputMergerFactory` | A `https://developer.android.com/reference/androidx/work/InputMergerFactory` for creating `https://developer.android.com/reference/androidx/work/InputMerger`s |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setJobSchedulerJobIdRange

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

```
public final @NonNull Configuration.Builder setJobSchedulerJobIdRange(int minJobSchedulerId, int maxJobSchedulerId)
```

Specifies the range of `https://developer.android.com/reference/android/app/job/JobInfo.html` IDs that can be used by `https://developer.android.com/reference/androidx/work/WorkManager`. WorkManager needs a range of at least `1000` IDs.

JobScheduler uses integers as identifiers for jobs, and WorkManager delegates to JobScheduler on certain API levels. In order to not clash job codes used in the rest of your app, you can use this method to tell WorkManager the valid range of job IDs that it can use.

The default values are `0` and `Integer#MAX_VALUE`.

| Parameters |
|---|---|
| `int minJobSchedulerId` | The first valid `https://developer.android.com/reference/android/app/job/JobInfo.html` ID (inclusive). |
| `int maxJobSchedulerId` | The last valid `https://developer.android.com/reference/android/app/job/JobInfo.html` ID (inclusive). |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | when the size of the range is less than 1000 |

### setMarkingJobsAsImportantWhileForeground

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

```
@ExperimentalConfigurationApi
public final @NonNull Configuration.Builder setMarkingJobsAsImportantWhileForeground(boolean markAsImportant)
```

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

It will have effects only on API levels \>= 23.

| Parameters |
|---|---|
| `boolean markAsImportant` | whether to mark jobs as important |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setMaxSchedulerLimit

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

```
public final @NonNull Configuration.Builder setMaxSchedulerLimit(int maxSchedulerLimit)
```

Specifies the maximum number of system requests made 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`.

By default, WorkManager might schedule a large number of alarms or JobScheduler jobs. If your app uses JobScheduler or AlarmManager directly, this might exhaust the OS-enforced limit on the number of jobs or alarms an app is allowed to schedule. To help manage this situation, you can use this method to reduce the number of underlying jobs and alarms that WorkManager might schedule.

When the application exceeds this limit, WorkManager maintains an internal queue of `https://developer.android.com/reference/androidx/work/WorkRequest`s, and schedules them when slots become free.

WorkManager requires a minimum of `https://developer.android.com/reference/androidx/work/Configuration#MIN_SCHEDULER_LIMIT()` slots; this is also the default value. The total number of slots also cannot exceed `50`.

| Parameters |
|---|---|
| `int maxSchedulerLimit` | The total number of jobs 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`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `maxSchedulerLimit` is less than `https://developer.android.com/reference/androidx/work/Configuration#MIN_SCHEDULER_LIMIT()` |

### setMinimumLoggingLevel

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

```
public final @NonNull Configuration.Builder setMinimumLoggingLevel(int loggingLevel)
```

Specifies the minimum logging level, corresponding to the constants found in `https://developer.android.com/reference/android/util/Log.html`. For example, specifying `https://developer.android.com/reference/android/util/Log.html#VERBOSE` will log everything, whereas specifying `https://developer.android.com/reference/android/util/Log.html#ERROR` will only log errors and assertions.The default value is `https://developer.android.com/reference/android/util/Log.html#INFO`.

| Parameters |
|---|---|
| `int loggingLevel` | The minimum logging level, corresponding to the constants found in `https://developer.android.com/reference/android/util/Log.html` |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setRemoteSessionTimeoutMillis

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

```
public final @NonNull Configuration.Builder setRemoteSessionTimeoutMillis(
    @IntRange(from = 0, to = 1200000) long timeoutMillis
)
```

Set how long in milliseconds that a `https://developer.android.com/reference/androidx/work/multiprocess/RemoteWorkManager` binding to the designated process stays active before timing out and unbinding.

The default timeout is `https://developer.android.com/reference/androidx/work/multiprocess/RemoteWorkManager#DEFAULT_SESSION_TIMEOUT_MILLIS()` and can be configured up to `https://developer.android.com/reference/androidx/work/multiprocess/RemoteWorkManager#MAX_SESSION_TIMEOUT_MILLIS()`. A timeout of 0 will unbind immediately after each call.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0, to = 1200000) long timeoutMillis` | Timeout in milliseconds before the session unbinds |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setRunnableScheduler

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

```
public final @NonNull Configuration.Builder setRunnableScheduler(@NonNull RunnableScheduler runnableScheduler)
```

Specifies the `https://developer.android.com/reference/androidx/work/RunnableScheduler` to be used by `https://developer.android.com/reference/androidx/work/WorkManager`.

This is used by the in-process scheduler to keep track of timed work.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/RunnableScheduler runnableScheduler` | The `https://developer.android.com/reference/androidx/work/RunnableScheduler` to be used |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setScheduleEventListener

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

```
@ExperimentalEventsApi
public final @NonNull Configuration.Builder setScheduleEventListener(@NonNull ScheduleEventListener listener)
```

Set a `https://developer.android.com/reference/androidx/work/ScheduleEventListener` to run whenever work scheduling events occur for any worker.

These callbacks will be invoked on a thread bound to `https://developer.android.com/reference/androidx/work/Configuration#taskExecutor()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ScheduleEventListener listener` | `https://developer.android.com/reference/androidx/work/ScheduleEventListener` to set |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setSchedulingExceptionHandler

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

```
public final @NonNull Configuration.Builder setSchedulingExceptionHandler(
    @NonNull Consumer<@NonNull Throwable> schedulingExceptionHandler
)
```

Specifies a `Consumer<Throwable>` that can be used to intercept exceptions caused when trying to schedule `https://developer.android.com/reference/androidx/work/WorkRequest`s.

It allows the application to handle a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html` throwable typically caused when trying to schedule `https://developer.android.com/reference/androidx/work/WorkRequest`s.

This exception handler will be invoked on a thread bound to `https://developer.android.com/reference/androidx/work/Configuration#taskExecutor()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull 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> schedulingExceptionHandler` | an instance to handle exceptions |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setTaskExecutor

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

```
public final @NonNull Configuration.Builder setTaskExecutor(@NonNull Executor taskExecutor)
```

Specifies a `https://developer.android.com/reference/java/util/concurrent/Executor.html` which will be used by WorkManager for all its internal book-keeping.

For best performance this `https://developer.android.com/reference/java/util/concurrent/Executor.html` should be bounded.

For more information look at androidx.room.RoomDatabase.Builder.setQueryExecutor.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html taskExecutor` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` which will be used by WorkManager for all its internal book-keeping |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setWorkerCoroutineContext

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

```
public final @NonNull Configuration.Builder setWorkerCoroutineContext(@NonNull CoroutineContext context)
```

Specifies a custom `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` to run `https://developer.android.com/reference/androidx/work/CoroutineWorker#doWork()`. WorkManager will use its own `Job` with the provided `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html`.

If `https://developer.android.com/reference/androidx/work/Configuration.Builder#setExecutor(java.util.concurrent.Executor)` wasn't called then `https://developer.android.com/reference/androidx/work/Configuration.Builder#setWorkerCoroutineContext(kotlin.coroutines.CoroutineContext)` will be used as `https://developer.android.com/reference/java/util/concurrent/Executor.html` to run `https://developer.android.com/reference/androidx/work/Worker` as well.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html context` | A `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` for running `https://developer.android.com/reference/androidx/work/CoroutineWorker`s |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setWorkerExecutionExceptionHandler

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

```
public final @NonNull Configuration.Builder setWorkerExecutionExceptionHandler(
    @NonNull Consumer<@NonNull WorkerExceptionInfo> workerExceptionHandler
)
```

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

This exception handler will be invoked on a thread bound to `https://developer.android.com/reference/androidx/work/Configuration#taskExecutor()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull 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> workerExceptionHandler` | an instance to handle exceptions |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setWorkerFactory

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

```
public final @NonNull Configuration.Builder setWorkerFactory(@NonNull WorkerFactory workerFactory)
```

Specifies a custom `https://developer.android.com/reference/androidx/work/WorkerFactory` for WorkManager.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerFactory workerFactory` | A `https://developer.android.com/reference/androidx/work/WorkerFactory` for creating `https://developer.android.com/reference/androidx/work/ListenableWorker`s |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |

### setWorkerInitializationExceptionHandler

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

```
public final @NonNull Configuration.Builder setWorkerInitializationExceptionHandler(
    @NonNull Consumer<@NonNull WorkerExceptionInfo> workerExceptionHandler
)
```

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

This exception handler will be invoked on a thread bound to `https://developer.android.com/reference/androidx/work/Configuration#taskExecutor()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull 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> workerExceptionHandler` | an instance to handle exceptions |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Configuration.Builder` | This `https://developer.android.com/reference/androidx/work/Configuration.Builder` instance |