Class WorkRequest.Builder
- Enclosing class:
WorkRequest
WorkRequest.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the immutable work request.putInputData(String key, String value) Adds a key-value pair to the input data passed to the worker.setInitialDelay(long millis) Sets an initial delay before the first execution.setPeriodic(long minIntervalMillis) Makes the work periodic with the given minimum interval.setRequiresBatteryNotLow(boolean b) Requires the battery to not be low (Android only).setRequiresCharging(boolean b) Requires the device to be charging.setRequiresIdle(boolean b) Requires the device to be idle (Android only).setRequiresNetwork(boolean b) Requires any network connection.setRequiresUnmeteredNetwork(boolean b) Requires an unmetered network connection.
-
Method Details
-
setRequiresNetwork
Requires any network connection.
Parameters
b: true to require a network
Returns
this builder for chaining
-
setRequiresUnmeteredNetwork
Requires an unmetered network connection.
Parameters
b: true to require an unmetered network
Returns
this builder for chaining
-
setRequiresCharging
Requires the device to be charging.
Parameters
b: true to require charging
Returns
this builder for chaining
-
setRequiresIdle
Requires the device to be idle (Android only).
Parameters
b: true to require device idle
Returns
this builder for chaining
-
setRequiresBatteryNotLow
Requires the battery to not be low (Android only).
Parameters
b: true to require battery-not-low
Returns
this builder for chaining
-
setPeriodic
Makes the work periodic with the given minimum interval. Note that platforms enforce a minimum period (for example 15 minutes on Android) and iOS only approximates periodic work by resubmission.
Parameters
minIntervalMillis: the minimum interval between executions in milliseconds
Returns
this builder for chaining
-
setInitialDelay
Sets an initial delay before the first execution.
Parameters
millis: the delay in milliseconds
Returns
this builder for chaining
-
putInputData
Adds a key-value pair to the input data passed to the worker.
Parameters
-
key: the key -
value: the value
Returns
this builder for chaining
-
-
build
Builds the immutable work request.
Returns
the work request
-