Criteria

public class Criteria
extends Object implements Parcelable

java.lang.Object
   ↳ android.location.Criteria


This class was deprecated in API level 34.
Criteria based APIs are deprecated because they cannot fully capture the complexity of location providers, and encourage bad development practices. Prefer to explicit select the location provider of interest (LocationManager#FUSED_PROVIDER, etc), rather than relying on Criteria.

A class indicating the application criteria for selecting a location provider. Providers may be ordered according to accuracy, power usage, ability to report altitude, speed, bearing, and monetary cost.

Summary

Constants

int ACCURACY_COARSE

A constant indicating an approximate accuracy requirement

int ACCURACY_FINE

A constant indicating a finer location accuracy requirement

int ACCURACY_HIGH

a constant indicating a high accuracy requirement - may be used for horizontal, altitude, speed or bearing accuracy.

int ACCURACY_LOW

A constant indicating a low location accuracy requirement - may be used for horizontal, altitude, speed or bearing accuracy.

int ACCURACY_MEDIUM

A constant indicating a medium accuracy requirement - currently used only for horizontal accuracy.

int NO_REQUIREMENT

A constant indicating that the application does not choose to place requirement on a particular feature.

int POWER_HIGH

A constant indicating a high power requirement.

int POWER_LOW

A constant indicating a low power requirement.

int POWER_MEDIUM

A constant indicating a medium power requirement.

Inherited constants

Fields

public static final Creator<Criteria> CREATOR

Public constructors

Criteria()

Constructs a new Criteria object.

Criteria(Criteria criteria)

Constructs a new Criteria object that is a copy of the given criteria.

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getAccuracy()

Returns a constant indicating desired accuracy of location.

int getBearingAccuracy()

Returns a constant indicating the desired bearing accuracy.

int getHorizontalAccuracy()

Returns a constant indicating the desired horizontal accuracy (latitude and longitude).

int getPowerRequirement()

Returns a constant indicating the desired maximum power requirement.

int getSpeedAccuracy()

Returns a constant indicating the desired speed accuracy.

int getVerticalAccuracy()

Returns a constant indicating the desired vertical accuracy (altitude).

boolean isAltitudeRequired()

Returns whether the provider must provide altitude information.

boolean isBearingRequired()

Returns whether the provider must provide bearing information.

boolean isCostAllowed()

Returns whether the provider is allowed to incur monetary cost.

boolean isSpeedRequired()

Returns whether the provider must provide speed information.

void setAccuracy(int accuracy)

Indicates the desired accuracy for latitude and longitude.

void setAltitudeRequired(boolean altitudeRequired)

Indicates whether the provider must provide altitude information.

void setBearingAccuracy(int accuracy)

Indicates the desired bearing accuracy.

void setBearingRequired(boolean bearingRequired)

Indicates whether the provider must provide bearing information.

void setCostAllowed(boolean costAllowed)

Indicates whether the provider is allowed to incur monetary cost.

void setHorizontalAccuracy(int accuracy)

Indicates the desired horizontal accuracy (latitude and longitude).

void setPowerRequirement(int powerRequirement)

Indicates the desired maximum power requirement.

void setSpeedAccuracy(int accuracy)

Indicates the desired speed accuracy.

void setSpeedRequired(boolean speedRequired)

Indicates whether the provider must provide speed information.

void setVerticalAccuracy(int accuracy)

Indicates the desired vertical accuracy (altitude).

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel parcel, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

ACCURACY_COARSE

Added in API level 1
public static final int ACCURACY_COARSE

A constant indicating an approximate accuracy requirement

Constant Value: 2 (0x00000002)

ACCURACY_FINE

Added in API level 1
public static final int ACCURACY_FINE

A constant indicating a finer location accuracy requirement

Constant Value: 1 (0x00000001)

ACCURACY_HIGH

Added in API level 9
Deprecated in API level 34
public static final int ACCURACY_HIGH

a constant indicating a high accuracy requirement - may be used for horizontal, altitude, speed or bearing accuracy. For horizontal and vertical position this corresponds roughly to an accuracy of less than 100 meters.

Constant Value: 3 (0x00000003)

ACCURACY_LOW

Added in API level 9
Deprecated in API level 34
public static final int ACCURACY_LOW

A constant indicating a low location accuracy requirement - may be used for horizontal, altitude, speed or bearing accuracy. For horizontal and vertical position this corresponds roughly to an accuracy of greater than 500 meters.

Constant Value: 1 (0x00000001)

ACCURACY_MEDIUM

Added in API level 9
Deprecated in API level 34
public static final int ACCURACY_MEDIUM

A constant indicating a medium accuracy requirement - currently used only for horizontal accuracy. For horizontal position this corresponds roughly to to an accuracy of between 100 and 500 meters.

Constant Value: 2 (0x00000002)

NO_REQUIREMENT

Added in API level 1
public static final int NO_REQUIREMENT

A constant indicating that the application does not choose to place requirement on a particular feature.

Constant Value: 0 (0x00000000)

POWER_HIGH

Added in API level 1
public static final int POWER_HIGH

A constant indicating a high power requirement.

Constant Value: 3 (0x00000003)

POWER_LOW

Added in API level 1
public static final int POWER_LOW

A constant indicating a low power requirement.

Constant Value: 1 (0x00000001)

POWER_MEDIUM

Added in API level 1
public static final int POWER_MEDIUM

A constant indicating a medium power requirement.

Constant Value: 2 (0x00000002)

Fields

CREATOR

Added in API level 1
public static final Creator<Criteria> CREATOR

Public constructors

Criteria

Added in API level 1
public Criteria ()

Constructs a new Criteria object. The new object will have no requirements on accuracy, power, or response time; will not require altitude, speed, or bearing; and will not allow monetary cost.

Criteria

Added in API level 1
public Criteria (Criteria criteria)

Constructs a new Criteria object that is a copy of the given criteria.

Parameters
criteria Criteria

Public methods

describeContents

Added in API level 1
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getAccuracy

Added in API level 1
public int getAccuracy ()

Returns a constant indicating desired accuracy of location.

Returns
int Value is NO_REQUIREMENT, ACCURACY_FINE, or ACCURACY_COARSE

See also:

getBearingAccuracy

Added in API level 9
Deprecated in API level 34
public int getBearingAccuracy ()

Returns a constant indicating the desired bearing accuracy.

Returns
int Value is NO_REQUIREMENT, ACCURACY_LOW, ACCURACY_MEDIUM, or ACCURACY_HIGH

getHorizontalAccuracy

Added in API level 9
Deprecated in API level 34
public int getHorizontalAccuracy ()

Returns a constant indicating the desired horizontal accuracy (latitude and longitude).

Returns
int Value is NO_REQUIREMENT, ACCURACY_LOW, ACCURACY_MEDIUM, or ACCURACY_HIGH

getPowerRequirement

Added in API level 1
public int getPowerRequirement ()

Returns a constant indicating the desired maximum power requirement.

Returns
int Value is NO_REQUIREMENT, POWER_LOW, POWER_MEDIUM, or POWER_HIGH

getSpeedAccuracy

Added in API level 9
Deprecated in API level 34
public int getSpeedAccuracy ()

Returns a constant indicating the desired speed accuracy.

Returns
int Value is NO_REQUIREMENT, ACCURACY_LOW, ACCURACY_MEDIUM, or ACCURACY_HIGH

getVerticalAccuracy

Added in API level 9
Deprecated in API level 34
public int getVerticalAccuracy ()

Returns a constant indicating the desired vertical accuracy (altitude).

Returns
int Value is NO_REQUIREMENT, ACCURACY_LOW, ACCURACY_MEDIUM, or ACCURACY_HIGH

isAltitudeRequired

Added in API level 1
public boolean isAltitudeRequired ()

Returns whether the provider must provide altitude information.

Returns
boolean

isBearingRequired

Added in API level 1
public boolean isBearingRequired ()

Returns whether the provider must provide bearing information.

Returns
boolean

isCostAllowed

Added in API level 1
public boolean isCostAllowed ()

Returns whether the provider is allowed to incur monetary cost.

Returns
boolean

isSpeedRequired

Added in API level 1
public boolean isSpeedRequired ()

Returns whether the provider must provide speed information.

Returns
boolean

setAccuracy

Added in API level 1
public void setAccuracy (int accuracy)

Indicates the desired accuracy for latitude and longitude. Accuracy may be ACCURACY_FINE or ACCURACY_COARSE. More accurate location may consume more power and may take longer.

Parameters
accuracy int: Value is NO_REQUIREMENT, ACCURACY_FINE, or ACCURACY_COARSE

Throws
IllegalArgumentException if accuracy is not one of the supported constants

setAltitudeRequired

Added in API level 1
public void setAltitudeRequired (boolean altitudeRequired)

Indicates whether the provider must provide altitude information. Not all fixes are guaranteed to contain such information.

Parameters
altitudeRequired boolean

setBearingAccuracy

Added in API level 9
Deprecated in API level 34
public void setBearingAccuracy (int accuracy)

Indicates the desired bearing accuracy. Accuracy may be ACCURACY_LOW, ACCURACY_MEDIUM, ACCURACY_HIGH, or NO_REQUIREMENT. More accurate location may consume more power and may take longer.

Parameters
accuracy int: Value is NO_REQUIREMENT, ACCURACY_LOW, ACCURACY_MEDIUM, or ACCURACY_HIGH

Throws
IllegalArgumentException if accuracy is not one of the supported constants

setBearingRequired

Added in API level 1
public void setBearingRequired (boolean bearingRequired)

Indicates whether the provider must provide bearing information. Not all fixes are guaranteed to contain such information.

Parameters
bearingRequired boolean

setCostAllowed

Added in API level 1
public void setCostAllowed (boolean costAllowed)

Indicates whether the provider is allowed to incur monetary cost.

Parameters
costAllowed boolean

setHorizontalAccuracy

Added in API level 9
Deprecated in API level 34
public void setHorizontalAccuracy (int accuracy)

Indicates the desired horizontal accuracy (latitude and longitude). Accuracy may be ACCURACY_LOW, ACCURACY_MEDIUM, ACCURACY_HIGH or NO_REQUIREMENT. More accurate location may consume more power and may take longer.

Parameters
accuracy int: Value is NO_REQUIREMENT, ACCURACY_LOW, ACCURACY_MEDIUM, or ACCURACY_HIGH

Throws
IllegalArgumentException if accuracy is not one of the supported constants

setPowerRequirement

Added in API level 1
public void setPowerRequirement (int powerRequirement)

Indicates the desired maximum power requirement. The power requirement parameter may be NO_REQUIREMENT, POWER_LOW, POWER_MEDIUM, or POWER_HIGH.

Parameters
powerRequirement int: Value is NO_REQUIREMENT, POWER_LOW, POWER_MEDIUM, or POWER_HIGH

setSpeedAccuracy

Added in API level 9
Deprecated in API level 34
public void setSpeedAccuracy (int accuracy)

Indicates the desired speed accuracy. Accuracy may be ACCURACY_LOW, ACCURACY_MEDIUM, ACCURACY_HIGH, or NO_REQUIREMENT. More accurate location may consume more power and may take longer.

Parameters
accuracy int: Value is NO_REQUIREMENT, ACCURACY_LOW, ACCURACY_MEDIUM, or ACCURACY_HIGH

Throws
IllegalArgumentException if accuracy is not one of the supported constants

setSpeedRequired

Added in API level 1
public void setSpeedRequired (boolean speedRequired)

Indicates whether the provider must provide speed information. Not all fixes are guaranteed to contain such information.

Parameters
speedRequired boolean

setVerticalAccuracy

Added in API level 9
Deprecated in API level 34
public void setVerticalAccuracy (int accuracy)

Indicates the desired vertical accuracy (altitude). Accuracy may be ACCURACY_LOW, ACCURACY_MEDIUM, ACCURACY_HIGH or NO_REQUIREMENT. More accurate location may consume more power and may take longer.

Parameters
accuracy int: Value is NO_REQUIREMENT, ACCURACY_LOW, ACCURACY_MEDIUM, or ACCURACY_HIGH

Throws
IllegalArgumentException if accuracy is not one of the supported constants

toString

Added in API level 1
public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.

writeToParcel

Added in API level 1
public void writeToParcel (Parcel parcel, 
                int flags)

Flatten this object in to a Parcel.

Parameters
parcel Parcel: The Parcel in which the object should be written. This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES