public class LocationProvider extends Object
Each provider has a set of criteria under which it may be used;
for example, some providers require GPS hardware and visibility to
a number of satellites; others require the use of the cellular
radio, or access to a specific carrier's network, or to the
internet. They may also have different battery consumption
characteristics or monetary costs to the user. The Criteria
class allows providers to be selected based on
user-specified criteria.
Modifier and Type | Field and Description |
---|---|
static int |
AVAILABLE |
static String |
BAD_CHARS_REGEX
A regular expression matching characters that may not appear
in the name of a LocationProvider
|
static int |
OUT_OF_SERVICE |
static int |
TEMPORARILY_UNAVAILABLE |
Constructor and Description |
---|
LocationProvider(String name,
ProviderProperties properties)
Constructs a LocationProvider with the given name.
|
Modifier and Type | Method and Description |
---|---|
int |
getAccuracy()
Returns a constant describing horizontal accuracy of this provider.
|
String |
getName()
Returns the name of this provider.
|
int |
getPowerRequirement()
Returns the power requirement for this provider.
|
boolean |
hasMonetaryCost()
Returns true if the use of this provider may result in a
monetary charge to the user, false if use is free.
|
boolean |
meetsCriteria(Criteria criteria)
Returns true if this provider meets the given criteria,
false otherwise.
|
static boolean |
propertiesMeetCriteria(String name,
ProviderProperties properties,
Criteria criteria) |
boolean |
requiresCell()
Returns true if the provider requires access to an appropriate
cellular network (e.g., to make use of cell tower IDs), false
otherwise.
|
boolean |
requiresNetwork()
Returns true if the provider requires access to a
data network (e.g., the Internet), false otherwise.
|
boolean |
requiresSatellite()
Returns true if the provider requires access to a
satellite-based positioning system (e.g., GPS), false
otherwise.
|
boolean |
supportsAltitude()
Returns true if the provider is able to provide altitude
information, false otherwise.
|
boolean |
supportsBearing()
Returns true if the provider is able to provide bearing
information, false otherwise.
|
boolean |
supportsSpeed()
Returns true if the provider is able to provide speed
information, false otherwise.
|
public static final int OUT_OF_SERVICE
public static final int TEMPORARILY_UNAVAILABLE
public static final int AVAILABLE
public static final String BAD_CHARS_REGEX
public LocationProvider(String name, ProviderProperties properties)
IllegalArgumentException
- if name contains an illegal characterpublic String getName()
public boolean meetsCriteria(Criteria criteria)
public static boolean propertiesMeetCriteria(String name, ProviderProperties properties, Criteria criteria)
public boolean requiresNetwork()
public boolean requiresSatellite()
public boolean requiresCell()
public boolean hasMonetaryCost()
public boolean supportsAltitude()
public boolean supportsSpeed()
public boolean supportsBearing()
public int getPowerRequirement()
public int getAccuracy()
Criteria.ACCURACY_FINE
is returned, otherwise if the
location is only approximate then Criteria.ACCURACY_COARSE
is returned.