Constraints

public final class Constraints
extends Object

java.lang.Object
   ↳ 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

class Constraints.Builder

A Builder for a Constraints object. 

Fields

public static final Constraints NONE

Represents a Constraints object with no requirements.

Public constructors

Constraints(Constraints other)

Public methods

boolean equals(Object o)
NetworkType getRequiredNetworkType()
int hashCode()
boolean requiresBatteryNotLow()
boolean requiresCharging()
boolean requiresDeviceIdle()
boolean requiresStorageNotLow()

Inherited methods

Fields

NONE

public static final Constraints NONE

Represents a Constraints object with no requirements.

Public constructors

Constraints

public Constraints (Constraints other)

Parameters
other Constraints

Public methods

equals

public boolean equals (Object o)

Parameters
o Object

Returns
boolean

getRequiredNetworkType

public NetworkType getRequiredNetworkType ()

Returns
NetworkType

hashCode

public int hashCode ()

Returns
int

requiresBatteryNotLow

public boolean requiresBatteryNotLow ()

Returns
boolean true if the work should only execute when the battery isn't low

requiresCharging

public boolean requiresCharging ()

Returns
boolean true if the work should only execute while the device is charging

requiresDeviceIdle

public boolean requiresDeviceIdle ()

Returns
boolean true if the work should only execute while the device is idle

requiresStorageNotLow

public boolean requiresStorageNotLow ()

Returns
boolean true if the work should only execute when the storage isn't low