|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.location.Location
public class 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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface android.os.Parcelable |
|---|
Parcelable.Creator<T> |
| Field Summary | |
|---|---|
static Parcelable.Creator<Location> |
CREATOR
|
static int |
FORMAT_DEGREES
Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD.DDDDD where D indicates degrees. |
static 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). |
static 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). |
| Fields inherited from interface android.os.Parcelable |
|---|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE |
| Constructor Summary | |
|---|---|
Location(Location l)
Constructs a new Location object that is a copy of the given location. |
|
Location(String provider)
Constructs a new Location. |
|
| Method Summary | |
|---|---|
float |
bearingTo(Location dest)
Returns the approximate initial bearing in degrees East of true North when traveling along the shortest path between this location and the given location. |
static String |
convert(double coordinate,
int outputType)
Converts a coordinate to a String representation. |
static double |
convert(String coordinate)
Converts a String in one of the formats described by FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS into a double. |
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation. |
static void |
distanceBetween(double startLatitude,
double startLongitude,
double endLatitude,
double endLongitude,
float[] results)
Computes the approximate distance in meters between two locations, and optionally the initial and final bearings of the shortest path between them. |
float |
distanceTo(Location dest)
Returns the approximate distance in meters between this location and the given location. |
float |
getAccuracy()
Returns the accuracy of the fix in meters. |
double |
getAltitude()
Returns the altitude of this fix. |
float |
getBearing()
Returns the direction of travel in degrees East of true North. |
Bundle |
getExtras()
Returns additional provider-specific information about the location fix as a Bundle. |
double |
getLatitude()
Returns the latitude of this fix. |
double |
getLongitude()
Returns the longitude of this fix. |
String |
getProvider()
Returns the name of the provider that generated this fix, or null if it is not associated with a provider. |
float |
getSpeed()
Returns the speed of the device over ground in meters/second. |
long |
getTime()
Returns the UTC time of this fix, in milliseconds since January 1, 1970. |
boolean |
hasAccuracy()
Returns true if the provider is able to report accuracy information, false otherwise. |
boolean |
hasAltitude()
Returns true if this fix contains altitude information, false otherwise. |
boolean |
hasBearing()
Returns true if the provider is able to report bearing information, false otherwise. |
boolean |
hasSpeed()
Returns true if this fix contains speed information, false otherwise. |
void |
removeAccuracy()
Clears the accuracy of this fix. |
void |
removeAltitude()
Clears the altitude of this fix. |
void |
removeBearing()
Clears the bearing of this fix. |
void |
removeSpeed()
Clears the speed of this fix. |
void |
reset()
Clears the contents of the location. |
void |
set(Location l)
Sets the contents of the location to the values from the given location. |
void |
setAccuracy(float accuracy)
Sets the accuracy of this fix. |
void |
setAltitude(double altitude)
Sets the altitude of this fix. |
void |
setBearing(float bearing)
Sets the bearing of this fix. |
void |
setExtras(Bundle extras)
Sets the extra information associated with this fix to the given Bundle. |
void |
setLatitude(double latitude)
Sets the latitude of this fix. |
void |
setLongitude(double longitude)
Sets the longitude of this fix. |
void |
setProvider(String provider)
Sets the name of the provider that generated this fix. |
void |
setSpeed(float speed)
Sets the speed of this fix, in meters/second. |
void |
setTime(long time)
Sets the UTC time of this fix, in milliseconds since January 1, 1970. |
String |
toString()
Returns a string containing a concise, human-readable description of the receiver. |
void |
writeToParcel(Parcel parcel,
int flags)
Flatten this object in to a Parcel. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int FORMAT_DEGREES
public static final int FORMAT_MINUTES
public static final int FORMAT_SECONDS
public static final Parcelable.Creator<Location> CREATOR
| Constructor Detail |
|---|
public Location(String provider)
provider - the name of the location provider that generated this
location fix.public Location(Location l)
| Method Detail |
|---|
public void set(Location l)
public void reset()
public static String convert(double coordinate,
int outputType)
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.public static double convert(String coordinate)
NullPointerException - if coordinate is null
IllegalArgumentException - if the coordinate is not
in one of the valid formats.
public static void distanceBetween(double startLatitude,
double startLongitude,
double endLatitude,
double endLongitude,
float[] results)
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 latitudestartLongitude - the starting longitudeendLatitude - the ending latitudeendLongitude - the ending longituderesults - an array of floats to hold the results
IllegalArgumentException - if results is null or has length < 1public float distanceTo(Location dest)
dest - the destination location
public float bearingTo(Location dest)
dest - the destination location
public String getProvider()
public void setProvider(String provider)
public long getTime()
public void setTime(long time)
public double getLatitude()
public void setLatitude(double latitude)
public double getLongitude()
public void setLongitude(double longitude)
public boolean hasAltitude()
public double getAltitude()
hasAltitude() is false,
0.0f is returned.
public void setAltitude(double altitude)
public void removeAltitude()
public boolean hasSpeed()
public float getSpeed()
public void setSpeed(float speed)
public void removeSpeed()
public boolean hasBearing()
public float getBearing()
public void setBearing(float bearing)
public void removeBearing()
public boolean hasAccuracy()
public float getAccuracy()
public void setAccuracy(float accuracy)
public void removeAccuracy()
public Bundle getExtras()
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.
public void setExtras(Bundle extras)
public String toString()
Object
toString in class Objectpublic int describeContents()
Parcelable
describeContents in interface Parcelable
public void writeToParcel(Parcel parcel,
int flags)
Parcelable
writeToParcel in interface Parcelableparcel - The Parcel in which the object should be written.flags - Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||