public class

Criteria

extends Object
java.lang.Object
   ↳ com.neomades.location.Criteria

Class Overview

The Criteria class lets user choose some criterias, that will be used by the platform when acquiring the location of the device.

Summary

Constants
int ACCURACY_DEFAULT A constant indicating an approximate accuracy requirement
int ACCURACY_FINE A constant indicating a finer location accuracy requirement
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.
Public Constructors
Criteria()
Constructs a new Criteria object.
Public Methods
int getAccuracy()
Returns the accuracy value set in this Criteria.
int getMinDistance()
Returns the minimum distance between two location updates in meters.
int getMinTime()
Returns the minimum time interval between two location updates in milliseconds.
int getPowerRequirement()
Returns the preferred power consumption.
boolean isAltitudeRequired()
Returns whether the location provider should be able to determine altitude.
boolean isCostAllowed()
Returns the preferred cost setting.
Criteria setAccuracy(int accuracy)
Sets the desired accuracy preference.
Criteria setAltitudeRequired(boolean altitudeRequired)
Sets whether the location provider should be able to determine altitude.
Criteria setCostAllowed(boolean costAllowed)
Indicates whether the provider is allowed to incur monetary cost.
Criteria setMinDistance(int minDistance)
Sets minimum distance between location updates, in meters
Criteria setMinTime(int minTime)
Sets the minimum time interval between location updates, in milliseconds.
Criteria setPowerRequirement(int level)
Sets the preferred maximum level of power consumption.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ACCURACY_DEFAULT

A constant indicating an approximate accuracy requirement

Constant Value: 4 (0x00000004)

public static final int ACCURACY_FINE

A constant indicating a finer location accuracy requirement

Constant Value: 5 (0x00000005)

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)

public static final int POWER_HIGH

A constant indicating a high power requirement.

Constant Value: 3 (0x00000003)

public static final int POWER_LOW

A constant indicating a low power requirement.

Constant Value: 1 (0x00000001)

public static final int POWER_MEDIUM

A constant indicating a medium power requirement.

Constant Value: 2 (0x00000002)

Public Constructors

public Criteria ()

Constructs a new Criteria object.

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

The default minimum time and minimum distance for updates value is 0.

Public Methods

public int getAccuracy ()

Returns the accuracy value set in this Criteria.

Returns

public int getMinDistance ()

Returns the minimum distance between two location updates in meters.

By default, the minimum distance is set to 0.

Returns
  • the minimum distance between two location updates in meters

public int getMinTime ()

Returns the minimum time interval between two location updates in milliseconds.

By default, the minimum time is set to 0.

Cross Platform Considerations

Not taken into account on iOS platform.

Returns
  • the minimum time interval between two location updates in milliseconds

public int getPowerRequirement ()

Returns the preferred power consumption.

Cross Platform Considerations

Not taken into account on iOS platform.

Returns

public boolean isAltitudeRequired ()

Returns whether the location provider should be able to determine altitude.

Cross Platform Considerations

Not taken into account on iOS platform.

Returns
  • whether the location provider should be able to determine altitude. true means that it should be able, false means that this is not required. Not all fixes are guaranteed to contain such information.

public boolean isCostAllowed ()

Returns the preferred cost setting.

Cross Platform Considerations

Not taken into account on iOS platform.

Returns
  • the preferred cost setting. true if allowed to cost, false if it must be free of charge.

public Criteria setAccuracy (int accuracy)

Sets the desired accuracy preference.

More accurate location may consume more power and may take longer.

Parameters
accuracy must be one of ACCURACY_FINE, ACCURACY_DEFAULT, or NO_REQUIREMENT.
Returns
  • the current criteria
Throws
IllegalArgumentException if the accuracy parameter is not one of the accuracy constants

public Criteria setAltitudeRequired (boolean altitudeRequired)

Sets whether the location provider should be able to determine altitude.

Cross Platform Considerations

Not taken into account on iOS platform.

Parameters
altitudeRequired if set to true, the LocationProvider is required to be able to normally determine the altitude. if set the false, the course is not required. Not all fixes are guaranteed to contain such information.
Returns
  • the current criteria

public Criteria setCostAllowed (boolean costAllowed)

Indicates whether the provider is allowed to incur monetary cost.

Cross Platform Considerations

Not taken into account on iOS platform.

Note that the platform implementation may not always be able to know if a location method implies cost to the end user or not. If the implementation doesn't know, it assumes that it may cost.

Parameters
costAllowed - false if location determination is not allowed to cost, true if it is allowed to cost. When this criteria is set to false, the implementation may only return a LocationProvider of which it is certain that it does not cause a per usage cost to the end user.
Returns
  • the current criteria

public Criteria setMinDistance (int minDistance)

Sets minimum distance between location updates, in meters

Parameters
minDistance - the minimum distance between location updates, in meters
Returns
  • the current criteria
Throws
IllegalArgumentException if min distance is negative

public Criteria setMinTime (int minTime)

Sets the minimum time interval between location updates, in milliseconds.

Parameters
minTime - the minimum time interval between location updates, in milliseconds
Returns
  • the current criteria
Throws
IllegalArgumentException if the min time is negative

public Criteria setPowerRequirement (int level)

Sets the preferred maximum level of power consumption.

Parameters
level - the preferred maximum level of power consumption; must be one of NO_REQUIREMENT, POWER_LOW, POWER_MEDIUM, or POWER_HIGH.
Returns
  • the current criteria
Throws
IllegalArgumentException if the level parameter is not one of the power constants