Added in API level 1

Location

open class Location : Parcelable
kotlin.Any
   ↳ android.location.Location

A data class representing a geographic location. A location consists of a latitude, longitude, timestamp, accuracy, and other information such as bearing, altitude and velocity.

All locations generated through LocationManager are guaranteed to have a valid latitude, longitude, timestamp (both Unix epoch time and elapsed realtime since boot), and accuracy. All other parameters are optional.

Note that Android provides the ability for applications to submit "mock" or faked locations through LocationManager, and that these locations can then be received by applications using LocationManager to obtain location information. These locations can be identified via the isMock() API. Applications that wish to determine if a given location represents the best estimate of the real position of the device as opposed to a fake location coming from another application or the user should use this API. Keep in mind that the user may have a good reason for mocking their location, and thus apps should generally reject mock locations only when it is essential to their use case that only real locations are accepted.

Summary

Constants
static Int

Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD.

static Int

Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD:MM.

static Int

Constant used to specify formatting of a latitude or longitude in the form "DDD:MM:SS.

Inherited constants
Public constructors
Location(provider: String?)

Constructs a new location with a named provider.

Location(location: Location)

Constructs a new location copied from the given location.

Public methods
open Float

Returns the approximate initial bearing in degrees east of true north when traveling along the shortest path between this location and the given location.

open static String
convert(coordinate: Double, outputType: Int)

Converts a latitude/longitude coordinate to a String representation.

open static Double
convert(coordinate: String)

Converts a String in one of the formats described by FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS into a double.

open Int

open static Unit
distanceBetween(startLatitude: Double, startLongitude: Double, endLatitude: Double, endLongitude: Double, results: FloatArray!)

Computes the approximate distance in meters between two locations, and optionally the initial and final bearings of the shortest path between them.

open Float

Returns the approximate distance in meters between this location and the given location.

open Unit
dump(pw: Printer, prefix: String?)

Dumps location information to the given Printer.

open Boolean
equals(other: Any?)

Location equality is provided primarily for test purposes.

open Float

Returns the estimated horizontal accuracy radius in meters of this location at the 68th percentile confidence level.

open Double

The altitude of this location in meters above the WGS84 reference ellipsoid.

open Float

Returns the bearing at the time of this location in degrees.

open Float

Returns the estimated bearing accuracy in degrees of this location at the 68th percentile confidence level.

open Long

A convenience methods that returns the age of this location in milliseconds with respect to the current elapsed realtime.

open Long
getElapsedRealtimeAgeMillis(referenceRealtimeMs: Long)

A convenience method that returns the age of this location with respect to the given reference elapsed realtime.

open Long

Return the time of this fix in milliseconds of elapsed realtime since system boot.

open Long

Return the time of this fix in nanoseconds of elapsed realtime since system boot.

open Double

Get the uncertainty in nanoseconds of the precision of getElapsedRealtimeNanos() at the 68th percentile confidence level.

open Bundle?

Returns an optional bundle of additional information associated with this location.

open Double

Get the latitude in degrees.

open Double

Get the longitude in degrees.

open Float

Returns the estimated Mean Sea Level altitude accuracy in meters of this location at the 68th percentile confidence level.

open Double

Returns the Mean Sea Level altitude of this location in meters.

open String?

Returns the name of the provider associated with this location.

open Float

Returns the speed at the time of this location in meters per second.

open Float

Returns the estimated speed accuracy in meters per second of this location at the 68th percentile confidence level.

open Long

Returns the Unix epoch time of this location fix, in milliseconds since the start of the Unix epoch (00:00:00 January 1, 1970 UTC).

open Float

Returns the estimated altitude accuracy in meters of this location at the 68th percentile confidence level.

open Boolean

Returns true if this location has a horizontal accuracy, false otherwise.

open Boolean

Returns true if this location has an altitude, false otherwise.

open Boolean

True if this location has a bearing, false otherwise.

open Boolean

Returns true if this location has a bearing accuracy, false otherwise.

open Boolean

True if this location has an elapsed realtime uncertainty, false otherwise.

open Boolean

Returns true if this location has a Mean Sea Level altitude, false otherwise.

open Boolean

Returns true if this location has a Mean Sea Level altitude accuracy, false otherwise.

open Boolean

True if this location has a speed, false otherwise.

open Boolean

Returns true if this location has a speed accuracy, false otherwise.

open Boolean

Returns true if this location has a vertical accuracy, false otherwise.

open Int

open Boolean

Return true if this location is considered complete.

open Boolean

Returns true if this is a mock location.

open Boolean

Returns true if this location is marked as a mock location.

open Unit

Remove the horizontal accuracy from this location.

open Unit

Removes the altitude from this location.

open Unit

Remove the bearing from this location.

open Unit

Remove the bearing accuracy from this location.

open Unit

Removes the elapsed realtime uncertainty from this location.

open Unit

Removes the Mean Sea Level altitude from this location.

open Unit

Removes the Mean Sea Level altitude accuracy from this location.

open Unit

Remove the speed from this location.

open Unit

Remove the speed accuracy from this location.

open Unit

Remove the vertical accuracy from this location.

open Unit

Sets the provider to null, removes all optional fields, and sets the values of all other fields to zero.

open Unit
set(location: Location)

Turns this location into a copy of the given location.

open Unit
setAccuracy(horizontalAccuracyMeters: Float)

Set the horizontal accuracy in meters of this location.

open Unit
setAltitude(altitudeMeters: Double)

Set the altitude of this location in meters above the WGS84 reference ellipsoid.

open Unit
setBearing(bearingDegrees: Float)

Set the bearing at the time of this location, in degrees.

open Unit
setBearingAccuracyDegrees(bearingAccuracyDegrees: Float)

Set the bearing accuracy in degrees of this location.

open Unit
setElapsedRealtimeNanos(elapsedRealtimeNs: Long)

Set the time of this location in nanoseconds of elapsed realtime since system boot.

open Unit
setElapsedRealtimeUncertaintyNanos(elapsedRealtimeUncertaintyNs: Double)

Sets the uncertainty in nanoseconds of the precision of the elapsed realtime timestamp at a 68% confidence level.

open Unit
setExtras(extras: Bundle?)

Sets the extra information associated with this fix to the given Bundle.

open Unit
setLatitude(latitudeDegrees: Double)

Set the latitude of this location.

open Unit
setLongitude(longitudeDegrees: Double)

Set the longitude of this location.

open Unit

Sets whether this location is marked as a mock location.

open Unit
setMslAltitudeAccuracyMeters(mslAltitudeAccuracyMeters: Float)

Sets the Mean Sea Level altitude accuracy of this location in meters.

open Unit
setMslAltitudeMeters(mslAltitudeMeters: Double)

Sets the Mean Sea Level altitude of this location in meters.

open Unit
setProvider(provider: String?)

Sets the name of the provider associated with this location

open Unit
setSpeed(speedMetersPerSecond: Float)

Set the speed at the time of this location, in meters per second.

open Unit
setSpeedAccuracyMetersPerSecond(speedAccuracyMeterPerSecond: Float)

Set the speed accuracy of this location in meters per second.

open Unit
setTime(timeMs: Long)

Sets the Unix epoch time of this location fix, in milliseconds since the start of the Unix epoch (00:00:00 January 1 1970 UTC).

open Unit
setVerticalAccuracyMeters(altitudeAccuracyMeters: Float)

Set the altitude accuracy of this location in meters.

open String

Returns a string representation of the object.

open Unit
writeToParcel(parcel: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<Location!>

Constants

FORMAT_DEGREES

Added in API level 1
static val FORMAT_DEGREES: Int

Constant used to specify formatting of a latitude or longitude in the form "[+-]DDD.DDDDD where D indicates degrees.

Value: 0

FORMAT_MINUTES

Added in API level 1
static val FORMAT_MINUTES: Int

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).

Value: 1

FORMAT_SECONDS

Added in API level 1
static val FORMAT_SECONDS: Int

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).

Value: 2

Public constructors

Location

Added in API level 1
Location(provider: String?)

Constructs a new location with a named provider. By default all values are zero, and no optional values are present.

Parameters
provider String?: the location provider name associated with this location This value may be null.

Location

Added in API level 1
Location(location: Location)

Constructs a new location copied from the given location.

Parameters
location Location: This value cannot be null.

Public methods

bearingTo

Added in API level 1
open fun bearingTo(dest: Location): Float

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 Location: the destination location This value cannot be null.
Return
Float the initial bearing in degrees

convert

Added in API level 1
open static fun convert(
    coordinate: Double,
    outputType: Int
): String

Converts a latitude/longitude coordinate to a String representation. The outputType must be one of FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS. The coordinate must be a number between -180.0 and 180.0, inclusive. This conversion is performed in a method that is dependent on the default locale, and so is not guaranteed to round-trip with convert(java.lang.String).

Parameters
outputType Int: Value is android.location.Location#FORMAT_DEGREES, android.location.Location#FORMAT_MINUTES, or android.location.Location#FORMAT_SECONDS
Return
String This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if outputType is not a recognized value.

convert

Added in API level 1
open static fun convert(coordinate: String): Double

Converts a String in one of the formats described by FORMAT_DEGREES, FORMAT_MINUTES, or FORMAT_SECONDS into a double. This conversion is performed in a locale agnostic method, and so is not guaranteed to round-trip with convert(double,int).

Parameters
coordinate String: This value cannot be null.
Exceptions
java.lang.NullPointerException if coordinate is null
java.lang.IllegalArgumentException if the coordinate is not in one of the valid formats.

describeContents

Added in API level 1
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

distanceBetween

Added in API level 1
open static fun distanceBetween(
    startLatitude: Double,
    startLongitude: Double,
    endLatitude: Double,
    endLongitude: Double,
    results: FloatArray!
): Unit

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 Double: the starting latitude Value is between -90.0 and 90.0 inclusive
startLongitude Double: the starting longitude Value is between -180.0 and 180.0 inclusive
endLatitude Double: the ending latitude Value is between -90.0 and 90.0 inclusive
endLongitude Double: the ending longitude Value is between -180.0 and 180.0 inclusive
results FloatArray!: an array of floats to hold the results
Exceptions
java.lang.IllegalArgumentException if results is null or has length < 1

distanceTo

Added in API level 1
open fun distanceTo(dest: Location): Float

Returns the approximate distance in meters between this location and the given location. Distance is defined using the WGS84 ellipsoid.

Parameters
dest Location: the destination location This value cannot be null.
Return
Float the approximate distance in meters Value is 0.0 or greater

dump

Added in API level 3
Deprecated in API level 33
open fun dump(
    pw: Printer,
    prefix: String?
): Unit

Deprecated: Prefer to use toString() along with whatever custom formatting is required instead of this method. It is not this class's job to manage print representations.

Dumps location information to the given Printer.

Parameters
pw Printer: This value cannot be null.
prefix String?: This value may be null.

equals

Added in API level 1
open fun equals(other: Any?): Boolean

Location equality is provided primarily for test purposes. Comparing locations for equality in production may indicate incorrect assumptions, and should be avoided whenever possible.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj the reference object with which to compare.
o This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getAccuracy

Added in API level 1
open fun getAccuracy(): Float

Returns the estimated horizontal accuracy radius in meters of this location at the 68th percentile confidence level. This means that there is a 68% chance that the true location of the device is within a distance of this uncertainty of the reported location. Another way of putting this is that if a circle with a radius equal to this accuracy is drawn around the reported location, there is a 68% chance that the true location falls within this circle. This accuracy value is only valid for horizontal positioning, and not vertical positioning.

This is only valid if hasAccuracy() is true. All locations generated by the LocationManager include horizontal accuracy.

Return
Float horizontal accuracy of this location Value is 0.0 or greater

getAltitude

Added in API level 1
open fun getAltitude(): Double

The altitude of this location in meters above the WGS84 reference ellipsoid.

This is only valid if hasAltitude() is true.

Return
Double altitude of this location

getBearing

Added in API level 1
open fun getBearing(): Float

Returns the bearing at the time of this location in degrees. Bearing is the horizontal direction of travel of this device and is unrelated to the device orientation. The bearing is guaranteed to be in the range [0, 360).

This is only valid if hasBearing() is true.

Return
Float bearing at the time of this location Value is between 0.0 and 360.0 inclusive

getBearingAccuracyDegrees

Added in API level 26
open fun getBearingAccuracyDegrees(): Float

Returns the estimated bearing accuracy in degrees of this location at the 68th percentile confidence level. This means that there is 68% chance that the true bearing at the time of this location falls within getBearing() ()} +/- this uncertainty.

This is only valid if hasBearingAccuracy() ()} is true.

Return
Float bearing accuracy in degrees of this location Value is 0.0 or greater

getElapsedRealtimeAgeMillis

Added in API level 33
open fun getElapsedRealtimeAgeMillis(): Long

A convenience methods that returns the age of this location in milliseconds with respect to the current elapsed realtime.

Return
Long age of this location in milliseconds Value is 0 or greater

getElapsedRealtimeAgeMillis

Added in API level 33
open fun getElapsedRealtimeAgeMillis(referenceRealtimeMs: Long): Long

A convenience method that returns the age of this location with respect to the given reference elapsed realtime.

Parameters
referenceRealtimeMs Long: reference realtime in milliseconds Value is 0 or greater
Return
Long age of this location in milliseconds

getElapsedRealtimeMillis

Added in API level 33
open fun getElapsedRealtimeMillis(): Long

Return the time of this fix in milliseconds of elapsed realtime since system boot.

Return
Long elapsed realtime of this location in milliseconds Value is 0 or greater

getElapsedRealtimeNanos

Added in API level 17
open fun getElapsedRealtimeNanos(): Long

Return the time of this fix in nanoseconds of elapsed realtime since system boot.

This value can be compared with android.os.SystemClock#elapsedRealtimeNanos to reliably order or compare locations. This is reliable because elapsed realtime is guaranteed to be monotonic and continues to increment even when the system is in deep sleep (unlike getTime). However, since elapsed realtime is with reference to system boot, it does not make sense to use this value to order or compare locations across boot cycles or devices.

All locations generated by the LocationManager are guaranteed to have a valid elapsed realtime set.

Return
Long elapsed realtime of this location in nanoseconds Value is 0 or greater

getElapsedRealtimeUncertaintyNanos

Added in API level 29
open fun getElapsedRealtimeUncertaintyNanos(): Double

Get the uncertainty in nanoseconds of the precision of getElapsedRealtimeNanos() at the 68th percentile confidence level. This means that there is 68% chance that the true elapsed realtime of this location is within getElapsedRealtimeNanos() +/- this uncertainty.

This is only valid if hasElapsedRealtimeUncertaintyNanos() is true.

Return
Double uncertainty in nanoseconds of the elapsed realtime of this location Value is 0.0 or greater

getExtras

Added in API level 1
open fun getExtras(): Bundle?

Returns an optional bundle of additional information associated with this location. The keys and values within the bundle are determined by the location provider.

Common key/value pairs are listed below. There is no guarantee that these key/value pairs will be present for any location.

  • satellites - the number of satellites used to derive a GNSS fix. This key was deprecated in API 34 because the information can be obtained through more accurate means, such as by referencing GnssStatus#usedInFix.
Return
Bundle? This value may be null.

getLatitude

Added in API level 1
open fun getLatitude(): Double

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

Return
Double latitude of this location Value is between -90.0 and 90.0 inclusive

getLongitude

Added in API level 1
open fun getLongitude(): Double

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

Return
Double longitude of this location Value is between -180.0 and 180.0 inclusive

getMslAltitudeAccuracyMeters

Added in API level 34
open fun getMslAltitudeAccuracyMeters(): Float

Returns the estimated Mean Sea Level altitude accuracy in meters of this location at the 68th percentile confidence level. This means that there is 68% chance that the true Mean Sea Level altitude of this location falls within getMslAltitudeMeters() +/- this uncertainty.

This is only valid if hasMslAltitudeAccuracy() is true.

Return
Float Value is 0.0 or greater

getMslAltitudeMeters

Added in API level 34
open fun getMslAltitudeMeters(): Double

Returns the Mean Sea Level altitude of this location in meters.

This is only valid if hasMslAltitude() is true.

getProvider

Added in API level 1
open fun getProvider(): String?

Returns the name of the provider associated with this location.

Return
String? the name of the provider This value may be null.

getSpeed

Added in API level 1
open fun getSpeed(): Float

Returns the speed at the time of this location in meters per second. Note that the speed returned here may be more accurate than would be obtained simply by calculating distance / time for sequential positions, such as if the Doppler measurements from GNSS satellites are taken into account.

This is only valid if hasSpeed() is true.

Return
Float speed at the time of this location Value is 0.0 or greater

getSpeedAccuracyMetersPerSecond

Added in API level 26
open fun getSpeedAccuracyMetersPerSecond(): Float

Returns the estimated speed accuracy in meters per second of this location at the 68th percentile confidence level. This means that there is 68% chance that the true speed at the time of this location falls within getSpeed() ()} +/- this uncertainty.

This is only valid if hasSpeedAccuracy() is true.

Return
Float vertical accuracy of this location Value is 0.0 or greater

getTime

Added in API level 1
open fun getTime(): Long

Returns the Unix epoch time of this location fix, in milliseconds since the start of the Unix epoch (00:00:00 January 1, 1970 UTC).

There is no guarantee that different locations have times set from the same clock. Locations derived from the LocationManager#GPS_PROVIDER are guaranteed to have their time originate from the clock in use by the satellite constellation that provided the fix. Locations derived from other providers may use any clock to set their time, though it is most common to use the device's Unix epoch time system clock (which may be incorrect).

Note that the device's Unix epoch time system clock is not monotonic; it can jump forwards or backwards unpredictably and may be changed at any time by the user, so this time should not be used to order or compare locations. Prefer getElapsedRealtimeNanos for that purpose, as the elapsed realtime clock is guaranteed to be monotonic.

On the other hand, this method may be useful for presenting a human-readable time to the user, or as a heuristic for comparing location fixes across reboot or across devices.

All locations generated by the LocationManager are guaranteed to have this time set, however remember that the device's system clock may have changed since the location was generated.

Return
Long the Unix epoch time of this location Value is 0 or greater

getVerticalAccuracyMeters

Added in API level 26
open fun getVerticalAccuracyMeters(): Float

Returns the estimated altitude accuracy in meters of this location at the 68th percentile confidence level. This means that there is 68% chance that the true altitude of this location falls within getAltitude() ()} +/- this uncertainty.

This is only valid if hasVerticalAccuracy() is true.

Return
Float vertical accuracy of this location Value is 0.0 or greater

hasAccuracy

Added in API level 1
open fun hasAccuracy(): Boolean

Returns true if this location has a horizontal accuracy, false otherwise.

hasAltitude

Added in API level 1
open fun hasAltitude(): Boolean

Returns true if this location has an altitude, false otherwise.

hasBearing

Added in API level 1
open fun hasBearing(): Boolean

True if this location has a bearing, false otherwise.

hasBearingAccuracy

Added in API level 26
open fun hasBearingAccuracy(): Boolean

Returns true if this location has a bearing accuracy, false otherwise.

hasElapsedRealtimeUncertaintyNanos

Added in API level 29
open fun hasElapsedRealtimeUncertaintyNanos(): Boolean

True if this location has an elapsed realtime uncertainty, false otherwise.

hasMslAltitude

Added in API level 34
open fun hasMslAltitude(): Boolean

Returns true if this location has a Mean Sea Level altitude, false otherwise.

hasMslAltitudeAccuracy

Added in API level 34
open fun hasMslAltitudeAccuracy(): Boolean

Returns true if this location has a Mean Sea Level altitude accuracy, false otherwise.

hasSpeed

Added in API level 1
open fun hasSpeed(): Boolean

True if this location has a speed, false otherwise.

hasSpeedAccuracy

Added in API level 26
open fun hasSpeedAccuracy(): Boolean

Returns true if this location has a speed accuracy, false otherwise.

hasVerticalAccuracy

Added in API level 26
open fun hasVerticalAccuracy(): Boolean

Returns true if this location has a vertical accuracy, false otherwise.

hashCode

Added in API level 1
open fun hashCode(): Int
Return
Int a hash code value for this object.

isComplete

Added in API level 33
open fun isComplete(): Boolean

Return true if this location is considered complete. A location is considered complete if it has a non-null provider, accuracy, and non-zero time and elapsed realtime. The exact definition of completeness may change over time.

All locations supplied by the LocationManager are guaranteed to be complete.

isFromMockProvider

Added in API level 18
Deprecated in API level 31
open fun isFromMockProvider(): Boolean

Deprecated: Prefer isMock() instead.

Returns true if this is a mock location. If this location comes from the Android framework, this indicates that the location was provided by a test location provider, and thus may not be related to the actual location of the device.

Return
Boolean true if this location came from a mock provider, false otherwise

isMock

Added in API level 31
open fun isMock(): Boolean

Returns true if this location is marked as a mock location. If this location comes from the Android framework, this indicates that the location was provided by a test location provider, and thus may not be related to the actual location of the device.

See Also

    removeAccuracy

    Added in API level 1
    Deprecated in API level 26
    open fun removeAccuracy(): Unit

    Remove the horizontal accuracy from this location.

    removeAltitude

    Added in API level 1
    Deprecated in API level 26
    open fun removeAltitude(): Unit

    Removes the altitude from this location.

    removeBearing

    Added in API level 1
    Deprecated in API level 26
    open fun removeBearing(): Unit

    Remove the bearing from this location.

    removeBearingAccuracy

    Added in API level 33
    open fun removeBearingAccuracy(): Unit

    Remove the bearing accuracy from this location.

    removeElapsedRealtimeUncertaintyNanos

    Added in API level 33
    open fun removeElapsedRealtimeUncertaintyNanos(): Unit

    Removes the elapsed realtime uncertainty from this location.

    removeMslAltitude

    Added in API level 34
    open fun removeMslAltitude(): Unit

    Removes the Mean Sea Level altitude from this location.

    removeMslAltitudeAccuracy

    Added in API level 34
    open fun removeMslAltitudeAccuracy(): Unit

    Removes the Mean Sea Level altitude accuracy from this location.

    removeSpeed

    Added in API level 1
    Deprecated in API level 26
    open fun removeSpeed(): Unit

    Remove the speed from this location.

    removeSpeedAccuracy

    Added in API level 33
    open fun removeSpeedAccuracy(): Unit

    Remove the speed accuracy from this location.

    removeVerticalAccuracy

    Added in API level 33
    open fun removeVerticalAccuracy(): Unit

    Remove the vertical accuracy from this location.

    reset

    Added in API level 1
    open fun reset(): Unit

    Sets the provider to null, removes all optional fields, and sets the values of all other fields to zero.

    set

    Added in API level 1
    open fun set(location: Location): Unit

    Turns this location into a copy of the given location.

    Parameters
    location Location: This value cannot be null.

    setAccuracy

    Added in API level 1
    open fun setAccuracy(horizontalAccuracyMeters: Float): Unit

    Set the horizontal accuracy in meters of this location.

    Parameters
    horizontalAccuracyMeters Float: horizontal altitude in meters Value is 0.0 or greater

    setAltitude

    Added in API level 1
    open fun setAltitude(altitudeMeters: Double): Unit

    Set the altitude of this location in meters above the WGS84 reference ellipsoid.

    Parameters
    altitudeMeters Double: altitude in meters

    setBearing

    Added in API level 1
    open fun setBearing(bearingDegrees: Float): Unit

    Set the bearing at the time of this location, in degrees. The given bearing will be converted into the range [0, 360).

    Note: passing in extremely high or low floating point values to this function may produce strange results due to the intricacies of floating point math.

    Parameters
    bearingDegrees Float: bearing in degrees

    setBearingAccuracyDegrees

    Added in API level 26
    open fun setBearingAccuracyDegrees(bearingAccuracyDegrees: Float): Unit

    Set the bearing accuracy in degrees of this location.

    Parameters
    bearingAccuracyDegrees Float: bearing accuracy in degrees Value is 0.0 or greater

    setElapsedRealtimeNanos

    Added in API level 17
    open fun setElapsedRealtimeNanos(elapsedRealtimeNs: Long): Unit

    Set the time of this location in nanoseconds of elapsed realtime since system boot.

    Parameters
    elapsedRealtimeNs Long: elapsed realtime in nanoseconds Value is 0 or greater

    setElapsedRealtimeUncertaintyNanos

    Added in API level 29
    open fun setElapsedRealtimeUncertaintyNanos(elapsedRealtimeUncertaintyNs: Double): Unit

    Sets the uncertainty in nanoseconds of the precision of the elapsed realtime timestamp at a 68% confidence level.

    Parameters
    elapsedRealtimeUncertaintyNs Double: uncertainty in nanoseconds of the elapsed realtime of this location Value is 0.0 or greater

    setExtras

    Added in API level 1
    open fun setExtras(extras: Bundle?): Unit

    Sets the extra information associated with this fix to the given Bundle.

    Note this stores a copy of the given extras, so any changes to extras after calling this method won't be reflected in the location bundle.

    Parameters
    extras Bundle?: This value may be null.

    setLatitude

    Added in API level 1
    open fun setLatitude(latitudeDegrees: Double): Unit

    Set the latitude of this location.

    Parameters
    latitudeDegrees Double: latitude in degrees Value is between -90.0 and 90.0 inclusive

    setLongitude

    Added in API level 1
    open fun setLongitude(longitudeDegrees: Double): Unit

    Set the longitude of this location.

    Parameters
    longitudeDegrees Double: longitude in degrees Value is between -180.0 and 180.0 inclusive

    setMock

    Added in API level 31
    open fun setMock(mock: Boolean): Unit

    Sets whether this location is marked as a mock location.

    setMslAltitudeAccuracyMeters

    Added in API level 34
    open fun setMslAltitudeAccuracyMeters(mslAltitudeAccuracyMeters: Float): Unit

    Sets the Mean Sea Level altitude accuracy of this location in meters.

    Parameters
    mslAltitudeAccuracyMeters Float: Value is 0.0 or greater

    setMslAltitudeMeters

    Added in API level 34
    open fun setMslAltitudeMeters(mslAltitudeMeters: Double): Unit

    Sets the Mean Sea Level altitude of this location in meters.

    setProvider

    Added in API level 1
    open fun setProvider(provider: String?): Unit

    Sets the name of the provider associated with this location

    Parameters
    provider String?: the name of the provider This value may be null.

    setSpeed

    Added in API level 1
    open fun setSpeed(speedMetersPerSecond: Float): Unit

    Set the speed at the time of this location, in meters per second.

    Parameters
    speedMetersPerSecond Float: speed in meters per second Value is 0.0 or greater

    setSpeedAccuracyMetersPerSecond

    Added in API level 26
    open fun setSpeedAccuracyMetersPerSecond(speedAccuracyMeterPerSecond: Float): Unit

    Set the speed accuracy of this location in meters per second.

    Parameters
    speedAccuracyMeterPerSecond Float: speed accuracy in meters per second Value is 0.0 or greater

    setTime

    Added in API level 1
    open fun setTime(timeMs: Long): Unit

    Sets the Unix epoch time of this location fix, in milliseconds since the start of the Unix epoch (00:00:00 January 1 1970 UTC).

    Parameters
    timeMs Long: the Unix epoch time of this location Value is 0 or greater

    setVerticalAccuracyMeters

    Added in API level 26
    open fun setVerticalAccuracyMeters(altitudeAccuracyMeters: Float): Unit

    Set the altitude accuracy of this location in meters.

    Parameters
    altitudeAccuracyMeters Float: altitude accuracy in meters Value is 0.0 or greater

    toString

    Added in API level 1
    open fun toString(): String

    Returns a string representation of the object.

    Return
    String This value cannot be null.

    writeToParcel

    Added in API level 1
    open fun writeToParcel(
        parcel: Parcel,
        flags: Int
    ): Unit

    Flatten this object in to a Parcel.

    Parameters
    dest The Parcel in which the object should be written. This value cannot be null.
    flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES
    parcel Parcel: This value cannot be null.

    Properties

    CREATOR

    Added in API level 1
    static val CREATOR: Parcelable.Creator<Location!>