Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Constraints

class Constraints
kotlin.Any
   ↳ androidx.work.Constraints

A specification of the requirements that need to be met before a WorkRequest can run. By default, WorkRequests do not have any requirements and can run immediately. By adding requirements, you can make sure that work only runs in certain situations - for example, when you have an unmetered network and are charging.

Summary

Nested classes

A Builder for a Constraints object.

Public constructors

<init>(@NonNull other: Constraints)

Public methods

Boolean
equals(other: Any?)

NetworkType

Int

Boolean

Boolean

Boolean

Boolean

Properties

static Constraints!

Represents a Constraints object with no requirements.

Public constructors

<init>

Constraints(@NonNull other: Constraints)

Public methods

equals

fun equals(other: Any?): Boolean

getRequiredNetworkType

@NonNull fun getRequiredNetworkType(): NetworkType

hashCode

fun hashCode(): Int

requiresBatteryNotLow

fun requiresBatteryNotLow(): Boolean
Return
Boolean: true if the work should only execute when the battery isn't low

requiresCharging

fun requiresCharging(): Boolean
Return
Boolean: true if the work should only execute while the device is charging

requiresDeviceIdle

fun requiresDeviceIdle(): Boolean
Return
Boolean: true if the work should only execute while the device is idle

requiresStorageNotLow

fun requiresStorageNotLow(): Boolean
Return
Boolean: true if the work should only execute when the storage isn't low

Properties

NONE

static val NONE: Constraints!

Represents a Constraints object with no requirements.