lightbulb_outline Please take our October 2018 developer survey. Start survey

Configuration.Builder

public static final class Configuration.Builder
extends Object

java.lang.Object
   ↳ androidx.work.Configuration.Builder


A Builder for Configuration.

Summary

Public constructors

Configuration.Builder()

Public methods

Configuration build()

Builds a Configuration object.

Configuration.Builder setExecutor(Executor executor)

Specifies a custom Executor for WorkManager.

Configuration.Builder setJobSchedulerJobIdRange(int minJobSchedulerId, int maxJobSchedulerId)

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

Configuration.Builder setMaxSchedulerLimit(int maxSchedulerLimit)

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

Configuration.Builder setMinimumLoggingLevel(int loggingLevel)

Specifies the minimum logging level.

Configuration.Builder setWorkerFactory(WorkerFactory workerFactory)

Specifies a custom WorkerFactory for WorkManager.

Inherited methods

Public constructors

Configuration.Builder

public Configuration.Builder ()

Public methods

build

public Configuration build ()

Builds a Configuration object.

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

setExecutor

public Configuration.Builder setExecutor (Executor executor)

Specifies a custom Executor for WorkManager.

Parameters
executor Executor: An Executor for processing work

Returns
Configuration.Builder This Configuration.Builder instance

setJobSchedulerJobIdRange

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

Specifies the range of JobInfo IDs that can be used by WorkManager. WorkManager needs a range of at least 1000 IDs.

Parameters
minJobSchedulerId int: The first valid JobInfo ID inclusive.

maxJobSchedulerId int: The last valid JobInfo ID inclusive.

Returns
Configuration.Builder This Configuration.Builder instance

Throws
IllegalArgumentException when the size of the range is < 1000

setMaxSchedulerLimit

public Configuration.Builder setMaxSchedulerLimit (int maxSchedulerLimit)

Specifies the maximum number of system requests made by WorkManager when using JobScheduler or AlarmManager. When the application exceeds this limit WorkManager maintains an internal queue of WorkRequests, and enqueues when slots become free. WorkManager requires a minimum of Configuration.MIN_SCHEDULER_LIMIT slots. The total number of slots also cannot exceed 50.

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

Returns
Configuration.Builder This Configuration.Builder instance

Throws
IllegalArgumentException when the number of jobs < Configuration.MIN_SCHEDULER_LIMIT

setMinimumLoggingLevel

public Configuration.Builder setMinimumLoggingLevel (int loggingLevel)

Specifies the minimum logging level.

Parameters
loggingLevel int: The minimum logging level, corresponding to the constants found in Log. For example, specifying Log.VERBOSE will log everything, whereas specifying Log.ERROR will only log errors and assertions. The default value is Log.INFO.

Returns
Configuration.Builder This Configuration.Builder instance

setWorkerFactory

public Configuration.Builder setWorkerFactory (WorkerFactory workerFactory)

Specifies a custom WorkerFactory for WorkManager.

Parameters
workerFactory WorkerFactory: A WorkerFactory for creating Workers

Returns
Configuration.Builder This Configuration.Builder instance