IT. Expert System.

Android Reference

Location


android.location

Class Location

  • All Implemented Interfaces:
    Parcelable


    public class Location
    extends Object
    implements Parcelable
    A data class representing a geographic location.

    A location can consist of a latitude, longitude, timestamp, and other information such as bearing, altitude and velocity.

    All locations generated by the LocationManager are guaranteed to have a valid latitude, longitude, and timestamp (both UTC time and elapsed real-time since boot), all other parameters are optional.

    • Field Summary

      Fields
      Modifier and Type Field and Description
      static Parcelable.Creator<Location> CREATOR
      static String EXTRA_COARSE_LOCATION
      Bundle key for a version of the location that has been fed through LocationFudger.
      static String EXTRA_NO_GPS_LOCATION
      Bundle key for a version of the location containing no GPS data.
      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).
    • Constructor Summary

      Constructors
      Constructor and Description
      Location(Location l)
      Construct a new Location object that is copied from an existing one.
      Location(String provider)
      Construct a new Location with a named provider.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      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.
      void dump(Printer pw, String prefix)
      float getAccuracy()
      Get the estimated accuracy of this location, in meters.
      double getAltitude()
      Get the altitude if available, in meters above sea level.
      float getBearing()
      Get the bearing, in degrees.
      long getElapsedRealtimeNanos()
      Return the time of this fix, in elapsed real-time since system boot.
      Location getExtraLocation(String key)
      Returns one of the optional extra Locations that can be attached to this Location.
      Bundle getExtras()
      Returns additional provider-specific information about the location fix as a Bundle.
      double getLatitude()
      Get the latitude, in degrees.
      double getLongitude()
      Get the longitude, in degrees.
      String getProvider()
      Returns the name of the provider that generated this fix.
      float getSpeed()
      Get the speed if it is available, in meters/second over ground.
      long getTime()
      Return the UTC time of this fix, in milliseconds since January 1, 1970.
      boolean hasAccuracy()
      True if this location has an accuracy.
      boolean hasAltitude()
      True if this location has an altitude.
      boolean hasBearing()
      True if this location has a bearing.
      boolean hasSpeed()
      True if this location has a speed.
      boolean isComplete()
      Return true if this Location object is complete.
      void makeComplete()
      Helper to fill incomplete fields.
      void removeAccuracy()
      Remove the accuracy from this location.
      void removeAltitude()
      Remove the altitude from this location.
      void removeBearing()
      Remove the bearing from this location.
      void removeSpeed()
      Remove the speed from this location.
      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)
      Set the estimated accuracy of this location, meters.
      void setAltitude(double altitude)
      Set the altitude, in meters above sea level.
      void setBearing(float bearing)
      Set the bearing, in degrees.
      void setElapsedRealtimeNanos(long time)
      Set the time of this fix, in elapsed real-time since system boot.
      void setExtraLocation(String key, Location value)
      Attaches an extra Location to this Location.
      void setExtras(Bundle extras)
      Sets the extra information associated with this fix to the given Bundle.
      void setLatitude(double latitude)
      Set the latitude, in degrees.
      void setLongitude(double longitude)
      Set the longitude, in degrees.
      void setProvider(String provider)
      Sets the name of the provider that generated this fix.
      void setSpeed(float speed)
      Set the speed, in meters/second over ground.
      void setTime(long time)
      Set the UTC time of this fix, in milliseconds since January 1, 1970.
      String toString()
      Returns a string containing a concise, human-readable description of this object.
      void writeToParcel(Parcel parcel, int flags)
      Flatten this object in to a Parcel.
    • Field Detail

      • FORMAT_DEGREES

        public static final int FORMAT_DEGREES
        Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD.DDDDD where D indicates degrees.
        See Also:
        Constant Field Values
      • FORMAT_MINUTES

        public static final 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).
        See Also:
        Constant Field Values
      • FORMAT_SECONDS

        public static final 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).
        See Also:
        Constant Field Values
      • EXTRA_COARSE_LOCATION

        public static final String EXTRA_COARSE_LOCATION
        Bundle key for a version of the location that has been fed through LocationFudger. Allows location providers to flag locations as being safe for use with ACCESS_COARSE_LOCATION permission.
        See Also:
        Constant Field Values
      • EXTRA_NO_GPS_LOCATION

        public static final String EXTRA_NO_GPS_LOCATION
        Bundle key for a version of the location containing no GPS data. Allows location providers to flag locations as being safe to feed to LocationFudger.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Location

        public Location(String provider)
        Construct a new Location with a named provider.

        By default time, latitude and longitude are 0, and the location has no bearing, altitude, speed, accuracy or extras.

        Parameters:
        provider - the name of the provider that generated this location
      • Location

        public Location(Location l)
        Construct a new Location object that is copied from an existing one.
    • Method Detail

      • set

        public void set(Location l)
        Sets the contents of the location to the values from the given location.
      • reset

        public void reset()
        Clears the contents of the location.
      • convert

        public static String convert(double coordinate,
                     int outputType)
        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.
        Throws:
        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.
      • convert

        public 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.
        Throws:
        NullPointerException - if coordinate is null
        IllegalArgumentException - if the coordinate is not in one of the valid formats.
      • distanceBetween

        public 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. 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].

        Parameters:
        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
        Throws:
        IllegalArgumentException - if results is null or has length < 1
      • distanceTo

        public float distanceTo(Location dest)
        Returns the approximate distance in meters between this location and the given location. Distance is defined using the WGS84 ellipsoid.
        Parameters:
        dest - the destination location
        Returns:
        the approximate distance in meters
      • bearingTo

        public 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. The shortest path is defined using the WGS84 ellipsoid. Locations that are (nearly) antipodal may produce meaningless results.
        Parameters:
        dest - the destination location
        Returns:
        the initial bearing in degrees
      • getProvider

        public String getProvider()
        Returns the name of the provider that generated this fix.
        Returns:
        the provider, or null if it has not been set
      • setProvider

        public void setProvider(String provider)
        Sets the name of the provider that generated this fix.
      • getTime

        public long getTime()
        Return the UTC time of this fix, in milliseconds since January 1, 1970.

        Note that the UTC time on a device is not monotonic: it can jump forwards or backwards unpredictably. So always use getElapsedRealtimeNanos() when calculating time deltas.

        On the other hand, getTime() is useful for presenting a human readable time to the user, or for carefully comparing location fixes across reboot or across devices.

        All locations generated by the LocationManager are guaranteed to have a valid UTC time, however remember that the system time may have changed since the location was generated.

        Returns:
        time of fix, in milliseconds since January 1, 1970.
      • setTime

        public void setTime(long time)
        Set the UTC time of this fix, in milliseconds since January 1, 1970.
        Parameters:
        time - UTC time of this fix, in milliseconds since January 1, 1970
      • getElapsedRealtimeNanos

        public long getElapsedRealtimeNanos()
        Return the time of this fix, in elapsed real-time since system boot.

        This value can be reliably compared to SystemClock.elapsedRealtimeNanos(), to calculate the age of a fix and to compare Location fixes. This is reliable because elapsed real-time is guaranteed monotonic for each system boot and continues to increment even when the system is in deep sleep (unlike getTime().

        All locations generated by the LocationManager are guaranteed to have a valid elapsed real-time.

        Returns:
        elapsed real-time of fix, in nanoseconds since system boot.
      • setElapsedRealtimeNanos

        public void setElapsedRealtimeNanos(long time)
        Set the time of this fix, in elapsed real-time since system boot.
        Parameters:
        time - elapsed real-time of fix, in nanoseconds since system boot.
      • getLatitude

        public double getLatitude()
        Get the latitude, in degrees.

        All locations generated by the LocationManager will have a valid latitude.

      • setLatitude

        public void setLatitude(double latitude)
        Set the latitude, in degrees.
      • getLongitude

        public double getLongitude()
        Get the longitude, in degrees.

        All locations generated by the LocationManager will have a valid longitude.

      • setLongitude

        public void setLongitude(double longitude)
        Set the longitude, in degrees.
      • hasAltitude

        public boolean hasAltitude()
        True if this location has an altitude.
      • getAltitude

        public double getAltitude()
        Get the altitude if available, in meters above sea level.

        If this location does not have an altitude then 0.0 is returned.

      • setAltitude

        public void setAltitude(double altitude)
        Set the altitude, in meters above sea level.

        Following this call hasAltitude() will return true.

      • removeAltitude

        public void removeAltitude()
        Remove the altitude from this location.

        Following this call hasAltitude() will return false, and getAltitude() will return 0.0.

      • hasSpeed

        public boolean hasSpeed()
        True if this location has a speed.
      • getSpeed

        public float getSpeed()
        Get the speed if it is available, in meters/second over ground.

        If this location does not have a speed then 0.0 is returned.

      • setSpeed

        public void setSpeed(float speed)
        Set the speed, in meters/second over ground.

        Following this call hasSpeed() will return true.

      • removeSpeed

        public void removeSpeed()
        Remove the speed from this location.

        Following this call hasSpeed() will return false, and getSpeed() will return 0.0.

      • hasBearing

        public boolean hasBearing()
        True if this location has a bearing.
      • getBearing

        public float getBearing()
        Get the bearing, in degrees.

        Bearing is the horizontal direction of travel of this device, and is not related to the device orientation. It is guaranteed to be in the range (0.0, 360.0] if the device has a bearing.

        If this location does not have a bearing then 0.0 is returned.

      • setBearing

        public void setBearing(float bearing)
        Set the bearing, in degrees.

        Bearing is the horizontal direction of travel of this device, and is not related to the device orientation.

        The input will be wrapped into the range (0.0, 360.0].

      • removeBearing

        public void removeBearing()
        Remove the bearing from this location.

        Following this call hasBearing() will return false, and getBearing() will return 0.0.

      • hasAccuracy

        public boolean hasAccuracy()
        True if this location has an accuracy.

        All locations generated by the LocationManager have an accuracy.

      • getAccuracy

        public float getAccuracy()
        Get the estimated accuracy of this location, in meters.

        We define accuracy as the radius of 68% confidence. In other words, if you draw a circle centered at this location's latitude and longitude, and with a radius equal to the accuracy, then there is a 68% probability that the true location is inside the circle.

        In statistical terms, it is assumed that location errors are random with a normal distribution, so the 68% confidence circle represents one standard deviation. Note that in practice, location errors do not always follow such a simple distribution.

        This accuracy estimation is only concerned with horizontal accuracy, and does not indicate the accuracy of bearing, velocity or altitude if those are included in this Location.

        If this location does not have an accuracy, then 0.0 is returned. All locations generated by the LocationManager include an accuracy.

      • setAccuracy

        public void setAccuracy(float accuracy)
        Set the estimated accuracy of this location, meters.

        See getAccuracy() for the definition of accuracy.

        Following this call hasAccuracy() will return true.

      • removeAccuracy

        public void removeAccuracy()
        Remove the accuracy from this location.

        Following this call hasAccuracy() will return false, and getAccuracy() will return 0.0.

      • isComplete

        public boolean isComplete()
        Return true if this Location object is complete.

        A location object is currently considered complete if it has a valid provider, accuracy, wall-clock time and elapsed real-time.

        All locations supplied by the LocationManager to applications must be complete.

        See Also:
        makeComplete()
      • makeComplete

        public void makeComplete()
        Helper to fill incomplete fields.

        Used to assist in backwards compatibility with Location objects received from applications.

        See Also:
        isComplete()
      • getExtras

        public Bundle getExtras()
        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.

        • satellites - the number of satellites used to derive the fix
      • setExtras

        public void setExtras(Bundle extras)
        Sets the extra information associated with this fix to the given Bundle.
      • toString

        public String toString()
        Description copied from class: Object
        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 is equivalent to the following expression:
           getClass().getName() + '@' + Integer.toHexString(hashCode())

        See Writing a useful toString method if you intend implementing your own toString method.

        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.
      • describeContents

        public int describeContents()
        Description copied from interface: Parcelable
        Describe the kinds of special objects contained in this Parcelable's marshalled representation.
        Specified by:
        describeContents in interface Parcelable
        Returns:
        a bitmask indicating the set of special object types marshalled by the Parcelable.
      • getExtraLocation

        public Location getExtraLocation(String key)
        Returns one of the optional extra Locations that can be attached to this Location.
        Parameters:
        key - the key associated with the desired extra Location
        Returns:
        the extra Location, or null if unavailable
      • setExtraLocation

        public void setExtraLocation(String key,
                            Location value)
        Attaches an extra Location to this Location.
        Parameters:
        key - the key associated with the Location extra
        location - the Location to attach


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 2192 / . Delta: 0.03468 с