java.lang.Object | |
↳ | android.location.Location |
A class representing a geographic location sensed at a particular time (a "fix"). A location consists of a latitude and longitude, a UTC timestamp. and optionally information on altitude, speed, and bearing.
Information specific to a particular provider or class of providers may be communicated to the application using getExtras, which returns a Bundle of key/value pairs. Each provider will only provide those entries for which information is available.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creator<Location> | CREATOR | ||||||||||
int | FORMAT_DEGREES | Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD.DDDDD where D indicates degrees. | |||||||||
int | FORMAT_MINUTES | Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD:MM.MMMMM" where D indicates degrees and M indicates minutes of arc (1 minute = 1/60th of a degree). | |||||||||
int | FORMAT_SECONDS | Constant used to specify formatting of a latitude or longitude in the form "DDD:MM:SS.SSSSS" where D indicates degrees, M indicates minutes of arc, and S indicates seconds of arc (1 minute = 1/60th of a degree, 1 second = 1/3600th of a degree). |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new Location.
| |||||||||||
Constructs a new Location object that is a copy of the given
location.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the approximate initial bearing in degrees East of true
North when traveling along the shortest path between this
location and the given location.
| |||||||||||
Converts a coordinate to a String representation.
| |||||||||||
Converts a String in one of the formats described by
FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS into a
double.
| |||||||||||
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
| |||||||||||
Computes the approximate distance in meters between two
locations, and optionally the initial and final bearings of the
shortest path between them.
| |||||||||||
Returns the approximate distance in meters between this
location and the given location.
| |||||||||||
Returns the accuracy of the fix in meters.
| |||||||||||
Returns the altitude of this fix.
| |||||||||||
Returns the direction of travel in degrees East of true
North.
| |||||||||||
Returns additional provider-specific information about the
location fix as a Bundle.
| |||||||||||
Returns the latitude of this fix.
| |||||||||||
Returns the longitude of this fix.
| |||||||||||
Returns the name of the provider that generated this fix,
or null if it is not associated with a provider.
| |||||||||||
Returns the speed of the device over ground in meters/second.
| |||||||||||
Returns the UTC time of this fix, in milliseconds since January 1,
1970.
| |||||||||||
Returns true if the provider is able to report accuracy information,
false otherwise.
| |||||||||||
Returns true if this fix contains altitude information, false
otherwise.
| |||||||||||
Returns true if the provider is able to report bearing information,
false otherwise.
| |||||||||||
Returns true if this fix contains speed information, false
otherwise.
| |||||||||||
Clears the accuracy of this fix.
| |||||||||||
Clears the altitude of this fix.
| |||||||||||
Clears the bearing of this fix.
| |||||||||||
Clears the speed of this fix.
| |||||||||||
Clears the contents of the location.
| |||||||||||
Sets the contents of the location to the values from the given location.
| |||||||||||
Sets the accuracy of this fix.
| |||||||||||
Sets the altitude of this fix.
| |||||||||||
Sets the bearing of this fix.
| |||||||||||
Sets the extra information associated with this fix to the
given Bundle.
| |||||||||||
Sets the latitude of this fix.
| |||||||||||
Sets the longitude of this fix.
| |||||||||||
Sets the name of the provider that generated this fix.
| |||||||||||
Sets the speed of this fix, in meters/second.
| |||||||||||
Sets the UTC time of this fix, in milliseconds since January 1,
1970.
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
| |||||||||||
Flatten this object in to a Parcel.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface android.os.Parcelable
|
Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD.DDDDD where D indicates degrees.
Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD:MM.MMMMM" where D indicates degrees and M indicates minutes of arc (1 minute = 1/60th of a degree).
Constant used to specify formatting of a latitude or longitude in the form "DDD:MM:SS.SSSSS" where D indicates degrees, M indicates minutes of arc, and S indicates seconds of arc (1 minute = 1/60th of a degree, 1 second = 1/3600th of a degree).
Constructs a new Location. By default, time, latitude, longitude, and numSatellites are 0; hasAltitude, hasSpeed, and hasBearing are false; and there is no extra information.
provider | the name of the location provider that generated this location fix. |
---|
Constructs a new Location object that is a copy of the given location.
Returns the approximate initial bearing in degrees East of true North when traveling along the shortest path between this location and the given location. The shortest path is defined using the WGS84 ellipsoid. Locations that are (nearly) antipodal may produce meaningless results.
dest | the destination location |
---|
Converts a coordinate to a String representation. The outputType may be one of FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS. The coordinate must be a valid double between -180.0 and 180.0.
IllegalArgumentException | if coordinate is less than -180.0, greater than 180.0, or is not a number. |
---|---|
IllegalArgumentException | if outputType is not one of FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS. |
Converts a String in one of the formats described by FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS into a double.
NullPointerException | if coordinate is null |
---|---|
IllegalArgumentException | if the coordinate is not in one of the valid formats. |
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
Computes the approximate distance in meters between two locations, and optionally the initial and final bearings of the shortest path between them. Distance and bearing are defined using the WGS84 ellipsoid.
The computed distance is stored in results[0]. If results has length 2 or greater, the initial bearing is stored in results[1]. If results has length 3 or greater, the final bearing is stored in results[2].
startLatitude | the starting latitude |
---|---|
startLongitude | the starting longitude |
endLatitude | the ending latitude |
endLongitude | the ending longitude |
results | an array of floats to hold the results |
IllegalArgumentException | if results is null or has length < 1 |
---|
Returns the approximate distance in meters between this location and the given location. Distance is defined using the WGS84 ellipsoid.
dest | the destination location |
---|
Returns the accuracy of the fix in meters. If hasAccuracy() is false, 0.0 is returned.
Returns the altitude of this fix. If hasAltitude() is false, 0.0f is returned.
Returns the direction of travel in degrees East of true North. If hasBearing() is false, 0.0 is returned.
Returns additional provider-specific information about the location fix as a Bundle. The keys and values are determined by the provider. If no additional information is available, null is returned.
A number of common key/value pairs are listed below. Providers that use any of the keys on this list must provide the corresponding value as described below.
Returns the latitude of this fix.
Returns the longitude of this fix.
Returns the name of the provider that generated this fix, or null if it is not associated with a provider.
Returns the speed of the device over ground in meters/second. If hasSpeed() is false, 0.0f is returned.
Returns the UTC time of this fix, in milliseconds since January 1, 1970.
Returns true if the provider is able to report accuracy information, false otherwise. The default implementation returns false.
Returns true if this fix contains altitude information, false otherwise.
Returns true if the provider is able to report bearing information, false otherwise. The default implementation returns false.
Returns true if this fix contains speed information, false otherwise. The default implementation returns false.
Clears the accuracy of this fix. Following this call, hasAccuracy() will return false.
Clears the altitude of this fix. Following this call, hasAltitude() will return false.
Clears the bearing of this fix. Following this call, hasBearing() will return false.
Clears the speed of this fix. Following this call, hasSpeed() will return false.
Clears the contents of the location.
Sets the contents of the location to the values from the given location.
Sets the accuracy of this fix. Following this call, hasAccuracy() will return true.
Sets the altitude of this fix. Following this call, hasAltitude() will return true.
Sets the bearing of this fix. Following this call, hasBearing() will return true.
Sets the extra information associated with this fix to the given Bundle.
Sets the latitude of this fix.
Sets the longitude of this fix.
Sets the name of the provider that generated this fix.
Sets the speed of this fix, in meters/second. Following this call, hasSpeed() will return true.
Sets the UTC time of this fix, in milliseconds since January 1, 1970.
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 simply concatenates the class name, the '@' sign and a hexadecimal representation of the object's hashCode(), that is, it is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Flatten this object in to a Parcel.
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. |