Builder
class Builder
kotlin.Any | |
↳ | androidx.work.Configuration.Builder |
A Builder for Configuration
s.
Summary
Public constructors | |
---|---|
<init>() Creates a new |
Public methods | |
---|---|
Configuration |
build() Builds a |
Configuration.Builder |
setDefaultProcessName(@NonNull processName: String) Designates the primary process that |
Configuration.Builder |
setExecutor(@NonNull executor: Executor) Specifies a custom |
Configuration.Builder |
setInputMergerFactory(@NonNull inputMergerFactory: InputMergerFactory) Specifies a custom |
Configuration.Builder |
setJobSchedulerJobIdRange(minJobSchedulerId: Int, maxJobSchedulerId: Int) Specifies the range of |
Configuration.Builder |
setMaxSchedulerLimit(maxSchedulerLimit: Int) Specifies the maximum number of system requests made by |
Configuration.Builder |
setMinimumLoggingLevel(loggingLevel: Int) Specifies the minimum logging level, corresponding to the constants found in |
Configuration.Builder |
setRunnableScheduler(@NonNull runnableScheduler: RunnableScheduler) Specifies the |
Configuration.Builder |
setTaskExecutor(@NonNull taskExecutor: Executor) Specifies a |
Configuration.Builder |
setWorkerFactory(@NonNull workerFactory: WorkerFactory) Specifies a custom |
Public constructors
Public methods
build
@NonNull fun build(): Configuration
Builds a Configuration
object.
Return | |
---|---|
Configuration |
A Configuration object with this Builder 's parameters. |
setDefaultProcessName
@NonNull fun setDefaultProcessName(@NonNull processName: String): Configuration.Builder
Designates the primary process that WorkManager
should schedule work in.
Parameters | |
---|---|
processName |
String: The String process name. |
Return | |
---|---|
Configuration.Builder |
This Builder instance |
setExecutor
@NonNull fun setExecutor(@NonNull executor: Executor): Configuration.Builder
Specifies a custom Executor
for WorkManager.
Parameters | |
---|---|
executor |
Executor: An Executor for running Worker s |
Return | |
---|---|
Configuration.Builder |
This Builder instance |
setInputMergerFactory
@NonNull fun setInputMergerFactory(@NonNull inputMergerFactory: InputMergerFactory): Configuration.Builder
Specifies a custom InputMergerFactory
for WorkManager.
Parameters | |
---|---|
inputMergerFactory |
InputMergerFactory: A InputMergerFactory for creating InputMerger s |
Return | |
---|---|
Configuration.Builder |
This Builder instance |
setJobSchedulerJobIdRange
@NonNull fun setJobSchedulerJobIdRange(
minJobSchedulerId: Int,
maxJobSchedulerId: Int
): Configuration.Builder
Specifies the range of android.app.job.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 android.app.job.JobInfo ID (inclusive). |
maxJobSchedulerId |
Int: The last valid android.app.job.JobInfo ID (inclusive). |
Return | |
---|---|
Configuration.Builder |
This Builder instance |
Exceptions | |
---|---|
IllegalArgumentException |
when the size of the range is less than 1000 |
setMaxSchedulerLimit
@NonNull fun setMaxSchedulerLimit(maxSchedulerLimit: Int): Configuration.Builder
Specifies the maximum number of system requests made by WorkManager
when using android.app.job.JobScheduler
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 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 android.app.job.JobScheduler . |
Return | |
---|---|
Configuration.Builder |
This Builder instance |
Exceptions | |
---|---|
IllegalArgumentException |
if maxSchedulerLimit is less than Configuration#MIN_SCHEDULER_LIMIT |
setMinimumLoggingLevel
@NonNull fun setMinimumLoggingLevel(loggingLevel: Int): Configuration.Builder
Specifies the minimum logging level, corresponding to the constants found in android.util.Log
. For example, specifying android.util.Log#VERBOSE
will log everything, whereas specifying android.util.Log#ERROR
will only log errors and assertions.The default value is android.util.Log#INFO
.
Parameters | |
---|---|
loggingLevel |
Int: The minimum logging level, corresponding to the constants found in android.util.Log |
Return | |
---|---|
Configuration.Builder |
This Builder instance |
setRunnableScheduler
@NonNull fun setRunnableScheduler(@NonNull runnableScheduler: RunnableScheduler): Configuration.Builder
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 |
Return | |
---|---|
Configuration.Builder |
This Builder instance |
setTaskExecutor
@NonNull fun setTaskExecutor(@NonNull taskExecutor: Executor): Configuration.Builder
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 androidx.room.RoomDatabase.Builder#setQueryExecutor(Executor)
.
Parameters | |
---|---|
taskExecutor |
Executor: The Executor which will be used by WorkManager for all its internal book-keeping |
Return | |
---|---|
Configuration.Builder |
This Builder instance |
setWorkerFactory
@NonNull fun setWorkerFactory(@NonNull workerFactory: WorkerFactory): Configuration.Builder
Specifies a custom WorkerFactory
for WorkManager.
Parameters | |
---|---|
workerFactory |
WorkerFactory: A WorkerFactory for creating ListenableWorker s |
Return | |
---|---|
Configuration.Builder |
This Builder instance |