LocationResult Stay organized with collections Save and categorize content based on your preferences.
Page Summary
LocationResult is a data class representing a geographic location result from the fused location provider.
Locations returned are guaranteed to have valid latitude, longitude, and UTC timestamp, and on API level 17+, elapsed real-time since boot.
The class provides methods to create a LocationResult, extract it from an Intent, get the latest location, or retrieve all locations.
You can check if an Intent contains a LocationResult using the
hasResultmethod.
A data class representing a geographic location result from the fused location provider.
All locations returned bygetLocations() are guaranteed to have a valid latitude, longitude, and UTC timestamp. On API level 17 or later they are also guaranteed to have elapsed real-time since boot. All other parameters are optional.
Inherited Constant Summary
| int | CONTENTS_FILE_DESCRIPTOR | |
| int | PARCELABLE_WRITE_RETURN_VALUE |
Field Summary
| public static finalCreator<LocationResult> | CREATOR |
Public Method Summary
| staticLocationResult | |
| boolean | |
| staticLocationResult | |
| Location | getLastLocation() Returns the most recent location available in this result, or null if no locations are available. |
| List<Location> | getLocations() Returns locations computed, ordered from oldest to newest. |
| static boolean | |
| int | hashCode() |
| String | toString() |
| void | writeToParcel(Parcel parcel, int flags) |
Inherited Method Summary
| abstract int | describeContents() |
| abstract void | writeToParcel(Parcel arg0, int arg1) |
Fields
public static finalCreator<LocationResult>CREATOR
Public Methods
public staticLocationResultcreate(List<Location> locations)
Creates aLocationResult for the given locations.
public booleanequals(Object o)
public staticLocationResultextractResult(Intent intent)
Extracts theLocationResult from an Intent.
This is a utility function which extracts theLocationResult from the extras of an Intent that was sent from the fused location provider.
Returns
- a
LocationResult, ornullif the Intent doesn't contain a result.
publicLocationgetLastLocation()
Returns the most recent location available in this result, or null if no locations are available.
publicList<Location>getLocations()
Returns locations computed, ordered from oldest to newest.
No duplicate locations will be returned to any given listener (i.e. locations will not overlap in time between subsequent calls to a listener).
public static booleanhasResult(Intent intent)
Returns true if an Intent contains aLocationResult.
This is a utility function that can be called from inside an intent receiver to make sure the received intent is from the fused location provider.
Returns
- true if the intent contains a
LocationResult, false otherwise.
public inthashCode()
publicStringtoString()
public voidwriteToParcel(Parcel parcel, int flags)
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.