LocationManager.GetLastKnownLocation(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the last known location from the given provider, or null if there is no last known location.
[Android.Runtime.Register("getLastKnownLocation", "(Ljava/lang/String;)Landroid/location/Location;", "GetGetLastKnownLocation_Ljava_lang_String_Handler")]
public virtual Android.Locations.Location? GetLastKnownLocation (string provider);
[<Android.Runtime.Register("getLastKnownLocation", "(Ljava/lang/String;)Landroid/location/Location;", "GetGetLastKnownLocation_Ljava_lang_String_Handler")>]
abstract member GetLastKnownLocation : string -> Android.Locations.Location
override this.GetLastKnownLocation : string -> Android.Locations.Location
Parameters
- provider
- String
a provider listed by #getAllProviders()
Returns
the last known location for the given provider, or null if not available
- Attributes
Exceptions
if no suitable permission is present
if provider is null or doesn't exist
Remarks
Gets the last known location from the given provider, or null if there is no last known location. The returned location may be quite old in some circumstances, so the age of the location should always be checked.
This will never activate sensors to compute a new location, and will only ever return a cached location.
See also #getCurrentLocation(String, CancellationSignal, Executor, Consumer)
which will always attempt to return a current location, but will potentially use additional power in the course of the attempt as compared to this method.
Java documentation for android.location.LocationManager.getLastKnownLocation(java.lang.String)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.