public final class

Configuration.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.work.Configuration.Builder

Overview

A Builder for Configurations.

Summary

Constructors
publicBuilder()

Creates a new Configuration.Builder.

publicBuilder(Configuration configuration)

Creates a new Configuration.Builder with an existing Configuration as its template.

Methods
public Configurationbuild()

Builds a Configuration object.

public Configuration.BuildersetDefaultProcessName(java.lang.String processName)

Designates the primary process that WorkManager should schedule work in.

public Configuration.BuildersetExecutor(java.util.concurrent.Executor executor)

Specifies a custom java.util.concurrent.Executor for WorkManager.

public Configuration.BuildersetInitializationExceptionHandler(InitializationExceptionHandler exceptionHandler)

Specifies the InitializationExceptionHandler that can be used to intercept exceptions caused when trying to initialize WorkManager.

public Configuration.BuildersetInputMergerFactory(InputMergerFactory inputMergerFactory)

Specifies a custom InputMergerFactory for WorkManager.

public Configuration.BuildersetJobSchedulerJobIdRange(int minJobSchedulerId, int maxJobSchedulerId)

Specifies the range of IDs that can be used by WorkManager.

public Configuration.BuildersetMaxSchedulerLimit(int maxSchedulerLimit)

Specifies the maximum number of system requests made by WorkManager when using or android.app.AlarmManager.

public Configuration.BuildersetMinimumLoggingLevel(int loggingLevel)

Specifies the minimum logging level, corresponding to the constants found in .

public Configuration.BuildersetRunnableScheduler(RunnableScheduler runnableScheduler)

Specifies the RunnableScheduler to be used by WorkManager.

public Configuration.BuildersetTaskExecutor(java.util.concurrent.Executor taskExecutor)

Specifies a java.util.concurrent.Executor which will be used by WorkManager for all its internal book-keeping.

public Configuration.BuildersetWorkerFactory(WorkerFactory workerFactory)

Specifies a custom WorkerFactory for WorkManager.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates a new Configuration.Builder.

public Builder(Configuration configuration)

Creates a new Configuration.Builder with an existing Configuration as its template.

Parameters:

configuration: An existing Configuration to use as a template

Methods

public Configuration.Builder setWorkerFactory(WorkerFactory workerFactory)

Specifies a custom WorkerFactory for WorkManager.

Parameters:

workerFactory: A WorkerFactory for creating ListenableWorkers

Returns:

This Configuration.Builder instance

public Configuration.Builder setInputMergerFactory(InputMergerFactory inputMergerFactory)

Specifies a custom InputMergerFactory for WorkManager.

Parameters:

inputMergerFactory: A InputMergerFactory for creating InputMergers

Returns:

This Configuration.Builder instance

public Configuration.Builder setExecutor(java.util.concurrent.Executor executor)

Specifies a custom java.util.concurrent.Executor for WorkManager.

Parameters:

executor: An java.util.concurrent.Executor for running Workers

Returns:

This Configuration.Builder instance

public Configuration.Builder setTaskExecutor(java.util.concurrent.Executor taskExecutor)

Specifies a java.util.concurrent.Executor which will be used by WorkManager for all its internal book-keeping. For best performance this java.util.concurrent.Executor should be bounded. For more information look at RoomDatabase.Builder.setQueryExecutor(Executor).

Parameters:

taskExecutor: The java.util.concurrent.Executor which will be used by WorkManager for all its internal book-keeping

Returns:

This Configuration.Builder instance

public Configuration.Builder setJobSchedulerJobIdRange(int minJobSchedulerId, int maxJobSchedulerId)

Specifies the range of IDs that can be used by 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:

minJobSchedulerId: The first valid ID (inclusive).
maxJobSchedulerId: The last valid ID (inclusive).

Returns:

This Configuration.Builder instance

public Configuration.Builder setMaxSchedulerLimit(int maxSchedulerLimit)

Specifies the maximum number of system requests made by WorkManager when using or android.app.AlarmManager.

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 WorkRequests, and schedules them when slots become free.

WorkManager requires a minimum of Configuration.MIN_SCHEDULER_LIMIT slots; this is also the default value. The total number of slots also cannot exceed 50.

Parameters:

maxSchedulerLimit: The total number of jobs which can be enqueued by WorkManager when using .

Returns:

This Configuration.Builder instance

public Configuration.Builder setMinimumLoggingLevel(int loggingLevel)

Specifies the minimum logging level, corresponding to the constants found in . For example, specifying will log everything, whereas specifying will only log errors and assertions.The default value is .

Parameters:

loggingLevel: The minimum logging level, corresponding to the constants found in

Returns:

This Configuration.Builder instance

public Configuration.Builder setRunnableScheduler(RunnableScheduler runnableScheduler)

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

Parameters:

runnableScheduler: The RunnableScheduler to be used

Returns:

This Configuration.Builder instance

public Configuration.Builder setInitializationExceptionHandler(InitializationExceptionHandler exceptionHandler)

Specifies the InitializationExceptionHandler that can be used to intercept exceptions caused when trying to initialize WorkManager.

Parameters:

exceptionHandler: The InitializationExceptionHandler instance.

Returns:

This Configuration.Builder instance

public Configuration.Builder setDefaultProcessName(java.lang.String processName)

Designates the primary process that WorkManager should schedule work in.

Parameters:

processName: The java.lang.String process name.

Returns:

This Configuration.Builder instance

public Configuration build()

Builds a Configuration object.

Returns:

A Configuration object with this Configuration.Builder's parameters.