Configuration.Builder
public
static
final
class
Configuration.Builder
extends Object
java.lang.Object | |
↳ | androidx.work.Configuration.Builder |
A Builder for Configuration
s.
Summary
Public constructors | |
---|---|
Builder()
Creates a new |
Public methods | |
---|---|
Configuration
|
build()
Builds a |
Configuration.Builder
|
setDefaultProcessName(String processName)
Designates the primary process that |
Configuration.Builder
|
setExecutor(Executor executor)
Specifies a custom |
Configuration.Builder
|
setInputMergerFactory(InputMergerFactory inputMergerFactory)
Specifies a custom |
Configuration.Builder
|
setJobSchedulerJobIdRange(int minJobSchedulerId, int maxJobSchedulerId)
Specifies the range of |
Configuration.Builder
|
setMaxSchedulerLimit(int maxSchedulerLimit)
Specifies the maximum number of system requests made by |
Configuration.Builder
|
setMinimumLoggingLevel(int loggingLevel)
Specifies the minimum logging level, corresponding to the constants found in
|
Configuration.Builder
|
setRunnableScheduler(RunnableScheduler runnableScheduler)
Specifies the |
Configuration.Builder
|
setTaskExecutor(Executor taskExecutor)
Specifies a |
Configuration.Builder
|
setWorkerFactory(WorkerFactory workerFactory)
Specifies a custom |
Inherited methods | |
---|---|
Public constructors
Public methods
build
public Configuration build ()
Builds a Configuration
object.
Returns | |
---|---|
Configuration |
A Configuration object with this Configuration.Builder 's parameters.
|
setDefaultProcessName
public Configuration.Builder setDefaultProcessName (String processName)
Designates the primary process that WorkManager
should schedule work in.
Parameters | |
---|---|
processName |
String : The String process name. |
Returns | |
---|---|
Configuration.Builder |
This Configuration.Builder instance
|
setExecutor
public Configuration.Builder setExecutor (Executor executor)
Specifies a custom Executor
for WorkManager.
Parameters | |
---|---|
executor |
Executor : An Executor for running Worker s |
Returns | |
---|---|
Configuration.Builder |
This Configuration.Builder instance
|
setInputMergerFactory
public Configuration.Builder setInputMergerFactory (InputMergerFactory inputMergerFactory)
Specifies a custom InputMergerFactory
for WorkManager.
Parameters | |
---|---|
inputMergerFactory |
InputMergerFactory : A InputMergerFactory for creating InputMerger s |
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.
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 |
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 less than 1000 |
setMaxSchedulerLimit
public Configuration.Builder setMaxSchedulerLimit (int maxSchedulerLimit)
Specifies the maximum number of system requests made by WorkManager
when using JobScheduler
or 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
WorkRequest
s, 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 |
int : The total number of jobs which can be enqueued by
WorkManager when using
JobScheduler . |
Returns | |
---|---|
Configuration.Builder |
This Configuration.Builder instance |
Throws | |
---|---|
IllegalArgumentException |
if maxSchedulerLimit is less than
Configuration.MIN_SCHEDULER_LIMIT
|
setMinimumLoggingLevel
public Configuration.Builder setMinimumLoggingLevel (int loggingLevel)
Specifies 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
.
Parameters | |
---|---|
loggingLevel |
int : The minimum logging level, corresponding to the constants found in
Log |
Returns | |
---|---|
Configuration.Builder |
This Configuration.Builder instance
|
setRunnableScheduler
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 |
RunnableScheduler : The RunnableScheduler to be used |
Returns | |
---|---|
Configuration.Builder |
This Configuration.Builder instance
|
setTaskExecutor
public Configuration.Builder setTaskExecutor (Executor taskExecutor)
Specifies a Executor
which will be used by WorkManager for all its
internal book-keeping.
For best performance this Executor
should be bounded.
For more information look at
RoomDatabase.Builder.setQueryExecutor(Executor)
.
Parameters | |
---|---|
taskExecutor |
Executor : The Executor which will be used by WorkManager for
all its internal book-keeping |
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 ListenableWorker s |
Returns | |
---|---|
Configuration.Builder |
This Configuration.Builder instance
|