@UnstableApi
public final class Requirements implements Parcelable


Defines a set of device state requirements.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = )
@IntDef(flag = true, value = )
public annotation Requirements.RequirementFlags

Requirement flags.

Constants

static final Parcelable.Creator<Requirements>
static final int

Requirement that the device is charging.

static final int

Requirement that the device is idle.

static final int

Requirement that the device's internal storage is not low.

static final int

Requirement that the device has network connectivity.

static final int

Requirement that the device has a network connection that is unmetered.

Public constructors

Public methods

boolean

Returns whether the requirements are met.

int
boolean
Requirements
filterRequirements(int requirementsFilter)

Filters the requirements, returning the subset that are enabled by the provided filter.

int

Returns requirements that are not met, or 0.

int

Returns the requirements.

int
boolean

Returns whether the device is required to be charging.

boolean

Returns whether the device is required to be idle.

boolean

Returns whether network connectivity is required.

boolean

Returns whether the device is required to not be low on internal storage.

boolean

Returns whether un-metered network connectivity is required.

void
writeToParcel(Parcel dest, int flags)

Inherited Constants

From android.os.Parcelable
static final int
static final int

Constants

CREATOR

public static final Parcelable.Creator<RequirementsCREATOR

DEVICE_CHARGING

public static final int DEVICE_CHARGING = 8

Requirement that the device is charging.

DEVICE_IDLE

public static final int DEVICE_IDLE = 4

Requirement that the device is idle.

DEVICE_STORAGE_NOT_LOW

public static final int DEVICE_STORAGE_NOT_LOW = 16

Requirement that the device's internal storage is not low. Note that this requirement is not affected by the status of external storage.

NETWORK

public static final int NETWORK = 1

Requirement that the device has network connectivity.

NETWORK_UNMETERED

public static final int NETWORK_UNMETERED = 2

Requirement that the device has a network connection that is unmetered.

Public fields

requirements

@Requirements.RequirementFlags
public final int requirements

Public constructors

Requirements

public Requirements(@Requirements.RequirementFlags int requirements)
Parameters
@Requirements.RequirementFlags int requirements

A combination of requirement flags.

Public methods

checkRequirements

public boolean checkRequirements(Context context)

Returns whether the requirements are met.

Parameters
Context context

Any context.

Returns
boolean

Whether the requirements are met.

describeContents

public int describeContents()

equals

public boolean equals(@Nullable Object o)

filterRequirements

public Requirements filterRequirements(int requirementsFilter)

Filters the requirements, returning the subset that are enabled by the provided filter.

Parameters
int requirementsFilter

The enabled RequirementFlags.

Returns
Requirements

The filtered requirements. If the filter does not cause a change in the requirements then this instance will be returned.

getNotMetRequirements

@Requirements.RequirementFlags
public int getNotMetRequirements(Context context)

Returns requirements that are not met, or 0.

Parameters
Context context

Any context.

Returns
int

The requirements that are not met, or 0.

getRequirements

@Requirements.RequirementFlags
public int getRequirements()

Returns the requirements.

hashCode

public int hashCode()

isChargingRequired

public boolean isChargingRequired()

Returns whether the device is required to be charging.

isIdleRequired

public boolean isIdleRequired()

Returns whether the device is required to be idle.

isNetworkRequired

public boolean isNetworkRequired()

Returns whether network connectivity is required.

isStorageNotLowRequired

public boolean isStorageNotLowRequired()

Returns whether the device is required to not be low on internal storage.

isUnmeteredNetworkRequired

public boolean isUnmeteredNetworkRequired()

Returns whether un-metered network connectivity is required.

writeToParcel

public void writeToParcel(Parcel dest, int flags)