Android APIs
public class

Criteria

extends Object
implements Parcelable
java.lang.Object
   ↳ android.location.Criteria

Class Overview

A class indicating the application criteria for selecting a location provider. Providers maybe ordered according to accuracy, power usage, ability to report altitude, speed, and 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.
[Expand]
Inherited Constants
From interface android.os.Parcelable
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's marshalled representation.
int getAccuracy()
Returns a constant indicating desired accuracy of location Accuracy may be ACCURACY_FINE if desired location is fine, else it can be ACCURACY_COARSE.
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 power requirement.
int getSpeedAccuracy()
Returns a constant indicating the desired speed accuracy Accuracy may be ACCURACY_LOW, ACCURACY_HIGH, or NO_REQUIREMENT.
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 level)
Indicates the desired maximum power level.
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 containing a concise, human-readable description of this object.
void writeToParcel(Parcel parcel, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final int ACCURACY_COARSE

Added in API level 1

A constant indicating an approximate accuracy requirement

Constant Value: 2 (0x00000002)

public static final int ACCURACY_FINE

Added in API level 1

A constant indicating a finer location accuracy requirement

Constant Value: 1 (0x00000001)

public static final int ACCURACY_HIGH

Added in API level 9

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)

public static final int ACCURACY_LOW

Added in API level 9

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)

public static final int ACCURACY_MEDIUM

Added in API level 9

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)

public static final int NO_REQUIREMENT

Added in API level 1

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

Constant Value: 0 (0x00000000)

public static final int POWER_HIGH

Added in API level 1

A constant indicating a high power requirement.

Constant Value: 3 (0x00000003)

public static final int POWER_LOW

Added in API level 1

A constant indicating a low power requirement.

Constant Value: 1 (0x00000001)

public static final int POWER_MEDIUM

Added in API level 1

A constant indicating a medium power requirement.

Constant Value: 2 (0x00000002)

Fields

public static final Creator<Criteria> CREATOR

Added in API level 1

Public Constructors

public Criteria ()

Added in API level 1

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.

public Criteria (Criteria criteria)

Added in API level 1

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

Public Methods

public int describeContents ()

Added in API level 1

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

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public int getAccuracy ()

Added in API level 1

Returns a constant indicating desired accuracy of location Accuracy may be ACCURACY_FINE if desired location is fine, else it can be ACCURACY_COARSE.

public int getBearingAccuracy ()

Added in API level 9

Returns a constant indicating the desired bearing accuracy. Accuracy may be ACCURACY_LOW, ACCURACY_HIGH, or NO_REQUIREMENT.

public int getHorizontalAccuracy ()

Added in API level 9

Returns a constant indicating the desired horizontal accuracy (latitude and longitude). Accuracy may be ACCURACY_LOW, ACCURACY_MEDIUM, ACCURACY_HIGH or NO_REQUIREMENT.

public int getPowerRequirement ()

Added in API level 1

Returns a constant indicating the desired power requirement. The returned

public int getSpeedAccuracy ()

Added in API level 9

Returns a constant indicating the desired speed accuracy Accuracy may be ACCURACY_LOW, ACCURACY_HIGH, or NO_REQUIREMENT.

public int getVerticalAccuracy ()

Added in API level 9

Returns a constant indicating the desired vertical accuracy (altitude). Accuracy may be ACCURACY_LOW, ACCURACY_HIGH, or NO_REQUIREMENT.

public boolean isAltitudeRequired ()

Added in API level 1

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

public boolean isBearingRequired ()

Added in API level 1

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

public boolean isCostAllowed ()

Added in API level 1

Returns whether the provider is allowed to incur monetary cost.

public boolean isSpeedRequired ()

Added in API level 1

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

public void setAccuracy (int accuracy)

Added in API level 1

Indicates the desired accuracy for latitude and longitude. Accuracy may be ACCURACY_FINE if desired location is fine, else it can be ACCURACY_COARSE. More accurate location may consume more power and may take longer.

Throws
IllegalArgumentException if accuracy is not one of the supported constants

public void setAltitudeRequired (boolean altitudeRequired)

Added in API level 1

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

public void setBearingAccuracy (int accuracy)

Added in API level 9

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

Throws
IllegalArgumentException if accuracy is not one of the supported constants

public void setBearingRequired (boolean bearingRequired)

Added in API level 1

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

public void setCostAllowed (boolean costAllowed)

Added in API level 1

Indicates whether the provider is allowed to incur monetary cost.

public void setHorizontalAccuracy (int accuracy)

Added in API level 9

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.

Throws
IllegalArgumentException if accuracy is not one of the supported constants

public void setPowerRequirement (int level)

Added in API level 1

Indicates the desired maximum power level. The level parameter must be one of NO_REQUIREMENT, POWER_LOW, POWER_MEDIUM, or POWER_HIGH.

public void setSpeedAccuracy (int accuracy)

Added in API level 9

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

Throws
IllegalArgumentException if accuracy is not one of the supported constants

public void setSpeedRequired (boolean speedRequired)

Added in API level 1

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

public void setVerticalAccuracy (int accuracy)

Added in API level 9

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.

Throws
IllegalArgumentException if accuracy is not one of the supported constants

public String toString ()

Added in API level 1

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public void writeToParcel (Parcel parcel, int flags)

Added in API level 1

Flatten this object in to a Parcel.

Parameters
parcel The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.