Constraints

@Serializable
data class Constraints(val requiresInternet: Boolean = false, val requiresCharging: Boolean = false, val batteryNotLow: Boolean = false, val requiresDeviceIdle: Boolean = false, val contentUris: List<String> = emptyList())

Platform conditions that must be satisfied before a task can execute.

Platform support matrix: | Constraint | Android | iOS | |--------------------|---------|---------| | requiresInternet | ✅ | Partial | | requiresCharging | ✅ | ❌ | | batteryNotLow | ✅ | ❌ |

On iOS, only internet connectivity is partially respected via BGProcessingTaskRequest.

Constructors

Link copied to clipboard
constructor(requiresInternet: Boolean = false, requiresCharging: Boolean = false, batteryNotLow: Boolean = false, requiresDeviceIdle: Boolean = false, contentUris: List<String> = emptyList())

Properties

Link copied to clipboard
val batteryNotLow: Boolean = false

Task should only run when battery level is not critically low. Android only.

Link copied to clipboard

Content URIs to observe for changes. Android only. When any of these URIs change, the task will be triggered.

Link copied to clipboard

Task should only run when the device is charging. Android only.

Link copied to clipboard

Task should only run when the device is idle. Android only (API 23+).

Link copied to clipboard

Task should only run when a network connection is available.