FileDocCategorySizeDatePackage
Criteria.javaAPI DocAndroid 1.5 API7743Wed May 06 22:42:00 BST 2009android.location

Criteria

public class Criteria extends Object implements android.os.Parcelable
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.

Fields Summary
public static final int
NO_REQUIREMENT
A constant indicating that the application does not choose to place requirement on a particular feature.
public static final int
POWER_LOW
A constant indicating a low power requirement.
public static final int
POWER_MEDIUM
A constant indicating a medium power requirement.
public static final int
POWER_HIGH
A constant indicating a high power requirement.
public static final int
ACCURACY_FINE
A constant indicating a finer location accuracy requirement
public static final int
ACCURACY_COARSE
A constant indicating an approximate accuracy requirement
private int
mAccuracy
private int
mPowerRequirement
private boolean
mAltitudeRequired
private boolean
mBearingRequired
private boolean
mSpeedRequired
private boolean
mCostAllowed
public static final Parcelable.Creator
CREATOR
Constructors Summary
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.


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

        mAccuracy = criteria.mAccuracy;
        mPowerRequirement = criteria.mPowerRequirement;
//        mPreferredResponseTime = criteria.mPreferredResponseTime;
        mAltitudeRequired = criteria.mAltitudeRequired;
        mBearingRequired = criteria.mBearingRequired;
        mSpeedRequired = criteria.mSpeedRequired;
        mCostAllowed = criteria.mCostAllowed;
    
Methods Summary
public intdescribeContents()


       
        return 0;
    
public intgetAccuracy()
Returns a constant indicating desired accuracy of location Accuracy may be {@link #ACCURACY_FINE} if desired location is fine, else it can be {@link #ACCURACY_COARSE}.

        return mAccuracy;
    
public intgetPowerRequirement()
Returns a constant indicating the desired power requirement. The returned

        return mPowerRequirement;
    
public booleanisAltitudeRequired()
Returns whether the provider must provide altitude information. Not all fixes are guaranteed to contain such information.

        return mAltitudeRequired;
    
public booleanisBearingRequired()
Returns whether the provider must provide bearing information. Not all fixes are guaranteed to contain such information.

        return mBearingRequired;
    
public booleanisCostAllowed()
Returns whether the provider is allowed to incur monetary cost.

        return mCostAllowed;
    
public booleanisSpeedRequired()
Returns whether the provider must provide speed information. Not all fixes are guaranteed to contain such information.

        return mSpeedRequired;
    
public voidsetAccuracy(int accuracy)
Indicates the desired accuracy for latitude and longitude. Accuracy may be {@link #ACCURACY_FINE} if desired location is fine, else it can be {@link #ACCURACY_COARSE}. More accurate location usually consumes more power and may take longer.

throws
IllegalArgumentException if accuracy is negative

        if (accuracy < NO_REQUIREMENT && accuracy > ACCURACY_COARSE) {
            throw new IllegalArgumentException("accuracy=" + accuracy);
        }
        mAccuracy = accuracy;
    
public voidsetAltitudeRequired(boolean altitudeRequired)
Indicates whether the provider must provide altitude information. Not all fixes are guaranteed to contain such information.

        mAltitudeRequired = altitudeRequired;
    
public voidsetBearingRequired(boolean bearingRequired)
Indicates whether the provider must provide bearing information. Not all fixes are guaranteed to contain such information.

        mBearingRequired = bearingRequired;
    
public voidsetCostAllowed(boolean costAllowed)
Indicates whether the provider is allowed to incur monetary cost.

        mCostAllowed = costAllowed;
    
public voidsetPowerRequirement(int level)
Indicates the desired maximum power level. The level parameter must be one of NO_REQUIREMENT, POWER_LOW, POWER_MEDIUM, or POWER_HIGH.

        if (level < NO_REQUIREMENT || level > POWER_HIGH) {
            throw new IllegalArgumentException("level=" + level);
        }
        mPowerRequirement = level;
    
public voidsetSpeedRequired(boolean speedRequired)
Indicates whether the provider must provide speed information. Not all fixes are guaranteed to contain such information.

        mSpeedRequired = speedRequired;
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)

        parcel.writeInt(mAccuracy);
        parcel.writeInt(mPowerRequirement);
//        parcel.writeInt(mPreferredResponseTime);
        parcel.writeInt(mAltitudeRequired ? 1 : 0);
        parcel.writeInt(mBearingRequired ? 1 : 0);
        parcel.writeInt(mSpeedRequired ? 1 : 0);
        parcel.writeInt(mCostAllowed ? 1 : 0);