Builder
class Builder
kotlin.Any | |
↳ | androidx.work.Constraints.Builder |
A Builder for a Constraints
object.
Summary
Public constructors | |
---|---|
<init>() |
Public methods | |
---|---|
Constraints.Builder |
addContentUriTrigger(@NonNull uri: Uri, triggerForDescendants: Boolean) Sets whether the |
Constraints |
build() Generates the |
Constraints.Builder |
setRequiredNetworkType(@NonNull networkType: NetworkType) Sets whether device should have a particular |
Constraints.Builder |
setRequiresBatteryNotLow(requiresBatteryNotLow: Boolean) Sets whether device battery should be at an acceptable level for the |
Constraints.Builder |
setRequiresCharging(requiresCharging: Boolean) Sets whether device should be charging for the |
Constraints.Builder |
setRequiresDeviceIdle(requiresDeviceIdle: Boolean) Sets whether device should be idle for the |
Constraints.Builder |
setRequiresStorageNotLow(requiresStorageNotLow: Boolean) Sets whether the device's available storage should be at an acceptable level for the |
Constraints.Builder |
setTriggerContentMaxDelay(duration: Long, @NonNull timeUnit: TimeUnit) Sets the maximum delay that is allowed from the first time a |
Constraints.Builder |
setTriggerContentMaxDelay(duration: Duration!) Sets the maximum delay that is allowed from the first time a |
Constraints.Builder |
setTriggerContentUpdateDelay(duration: Long, @NonNull timeUnit: TimeUnit) Sets the delay that is allowed from the time a |
Constraints.Builder |
setTriggerContentUpdateDelay(duration: Duration!) Sets the delay that is allowed from the time a |
Public constructors
<init>
Builder()
Public methods
addContentUriTrigger
@RequiresApi(24) @NonNull fun addContentUriTrigger(
@NonNull uri: Uri,
triggerForDescendants: Boolean
): Constraints.Builder
Sets whether the WorkRequest
should run when a local content:
Uri
is updated. This functionality is identical to the one found in JobScheduler
and is described in JobInfo.Builder#addTriggerContentUri(android.app.job.JobInfo.TriggerContentUri)
.
Parameters | |
---|---|
uri |
Uri: The local content: Uri to observe |
triggerForDescendants |
Boolean: true if any changes in descendants cause this WorkRequest to run |
Return | |
---|---|
Constraints.Builder |
The current Builder |
build
@NonNull fun build(): Constraints
Generates the Constraints
from this Builder.
Return | |
---|---|
Constraints |
The Constraints specified by this Builder |
setRequiredNetworkType
@NonNull fun setRequiredNetworkType(@NonNull networkType: NetworkType): Constraints.Builder
Sets whether device should have a particular NetworkType
for the WorkRequest
to run. The default value is NetworkType#NOT_REQUIRED
.
Parameters | |
---|---|
networkType |
NetworkType: The type of network required for the work to run |
Return | |
---|---|
Constraints.Builder |
The current Builder |
setRequiresBatteryNotLow
@NonNull fun setRequiresBatteryNotLow(requiresBatteryNotLow: Boolean): Constraints.Builder
Sets whether device battery should be at an acceptable level for the WorkRequest
to run. The default value is false
.
Parameters | |
---|---|
requiresBatteryNotLow |
Boolean: true if the battery should be at an acceptable level for the work to run |
Return | |
---|---|
Constraints.Builder |
The current Builder |
setRequiresCharging
@NonNull fun setRequiresCharging(requiresCharging: Boolean): Constraints.Builder
Sets whether device should be charging for the WorkRequest
to run. The default value is false
.
Parameters | |
---|---|
requiresCharging |
Boolean: true if device must be charging for the work to run |
Return | |
---|---|
Constraints.Builder |
The current Builder |
setRequiresDeviceIdle
@RequiresApi(23)