LocationManager.RequestLocationUpdates Method

Definition

Overloads

RequestLocationUpdates(String, LocationRequest, PendingIntent)

Register for location updates from the specified provider, using a LocationRequest, and callbacks delivered via the provided PendingIntent.

RequestLocationUpdates(Int64, Single, Criteria, PendingIntent)

Register for location updates using a provider selected through the given Criteria, and callbacks delivered via the provided PendingIntent.

RequestLocationUpdates(String, LocationRequest, IExecutor, ILocationListener)

Register for location updates from the specified provider, using a LocationRequest, and a callback on the specified Executor.

RequestLocationUpdates(String, Int64, Single, PendingIntent)

Register for location updates using the named provider, and callbacks delivered via the provided PendingIntent.

RequestLocationUpdates(String, Int64, Single, ILocationListener)

Register for location updates from the given provider with the given arguments, and a callback on the Looper of the calling thread.

RequestLocationUpdates(Int64, Single, Criteria, ILocationListener, Looper)

Register for location updates using a provider selected through the given Criteria, and a callback on the specified Looper.

RequestLocationUpdates(Int64, Single, Criteria, IExecutor, ILocationListener)

Register for location updates using a provider selected through the given Criteria, and a callback on the specified Executor.

RequestLocationUpdates(String, Int64, Single, ILocationListener, Looper)

Register for location updates from the given provider with the given arguments, and a callback on the specified Looper.

RequestLocationUpdates(String, Int64, Single, IExecutor, ILocationListener)

Register for location updates using the named provider, and a callback on the specified Executor.

RequestLocationUpdates(String, LocationRequest, PendingIntent)

Register for location updates from the specified provider, using a LocationRequest, and callbacks delivered via the provided PendingIntent.

[Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;Landroid/location/LocationRequest;Landroid/app/PendingIntent;)V", "GetRequestLocationUpdates_Ljava_lang_String_Landroid_location_LocationRequest_Landroid_app_PendingIntent_Handler", ApiSince=31)]
public virtual void RequestLocationUpdates (string provider, Android.Locations.LocationRequest locationRequest, Android.App.PendingIntent pendingIntent);
[<Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;Landroid/location/LocationRequest;Landroid/app/PendingIntent;)V", "GetRequestLocationUpdates_Ljava_lang_String_Landroid_location_LocationRequest_Landroid_app_PendingIntent_Handler", ApiSince=31)>]
abstract member RequestLocationUpdates : string * Android.Locations.LocationRequest * Android.App.PendingIntent -> unit
override this.RequestLocationUpdates : string * Android.Locations.LocationRequest * Android.App.PendingIntent -> unit

Parameters

provider
String

a provider listed by #getAllProviders()

locationRequest
LocationRequest

the location request containing location parameters

pendingIntent
PendingIntent

the pending intent to send location updates

Attributes

Remarks

Register for location updates from the specified provider, using a LocationRequest, and callbacks delivered via the provided PendingIntent.

The delivered pending intents will contain extras with the callback information. The keys used for the extras are #KEY_LOCATION_CHANGED and #KEY_PROVIDER_ENABLED. See the documentation for each respective extra key for information on the values.

To unregister for location updates, use #removeUpdates(PendingIntent).

Java documentation for android.location.LocationManager.requestLocationUpdates(java.lang.String, android.location.LocationRequest, android.app.PendingIntent).

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.

Applies to

RequestLocationUpdates(Int64, Single, Criteria, PendingIntent)

Register for location updates using a provider selected through the given Criteria, and callbacks delivered via the provided PendingIntent.

[Android.Runtime.Register("requestLocationUpdates", "(JFLandroid/location/Criteria;Landroid/app/PendingIntent;)V", "GetRequestLocationUpdates_JFLandroid_location_Criteria_Landroid_app_PendingIntent_Handler")]
public virtual void RequestLocationUpdates (long minTimeMs, float minDistanceM, Android.Locations.Criteria criteria, Android.App.PendingIntent pendingIntent);
[<Android.Runtime.Register("requestLocationUpdates", "(JFLandroid/location/Criteria;Landroid/app/PendingIntent;)V", "GetRequestLocationUpdates_JFLandroid_location_Criteria_Landroid_app_PendingIntent_Handler")>]
abstract member RequestLocationUpdates : int64 * single * Android.Locations.Criteria * Android.App.PendingIntent -> unit
override this.RequestLocationUpdates : int64 * single * Android.Locations.Criteria * Android.App.PendingIntent -> unit

Parameters

minTimeMs
Int64

minimum time interval between location updates in milliseconds

minDistanceM
Single

minimum distance between location updates in meters

criteria
Criteria

contains parameters to choose the appropriate provider for location updates

pendingIntent
PendingIntent

the pending intent to send location updates

Attributes

Exceptions

if criteria is null

if intent is null

if no suitable permission is present

Remarks

Register for location updates using a provider selected through the given Criteria, and callbacks delivered via the provided PendingIntent.

Note: Since Android KitKat, Criteria requests will always result in using the #FUSED_PROVIDER.

See #requestLocationUpdates(String, long, float, PendingIntent) for more detail on how this method works.

This member is deprecated. Use #requestLocationUpdates(String, long, float, PendingIntent) instead to explicitly select a provider.

Java documentation for android.location.LocationManager.requestLocationUpdates(long, float, android.location.Criteria, android.app.PendingIntent).

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.

Applies to

RequestLocationUpdates(String, LocationRequest, IExecutor, ILocationListener)

Register for location updates from the specified provider, using a LocationRequest, and a callback on the specified Executor.

[Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;Landroid/location/LocationRequest;Ljava/util/concurrent/Executor;Landroid/location/LocationListener;)V", "GetRequestLocationUpdates_Ljava_lang_String_Landroid_location_LocationRequest_Ljava_util_concurrent_Executor_Landroid_location_LocationListener_Handler", ApiSince=31)]
public virtual void RequestLocationUpdates (string provider, Android.Locations.LocationRequest locationRequest, Java.Util.Concurrent.IExecutor executor, Android.Locations.ILocationListener listener);
[<Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;Landroid/location/LocationRequest;Ljava/util/concurrent/Executor;Landroid/location/LocationListener;)V", "GetRequestLocationUpdates_Ljava_lang_String_Landroid_location_LocationRequest_Ljava_util_concurrent_Executor_Landroid_location_LocationListener_Handler", ApiSince=31)>]
abstract member RequestLocationUpdates : string * Android.Locations.LocationRequest * Java.Util.Concurrent.IExecutor * Android.Locations.ILocationListener -> unit
override this.RequestLocationUpdates : string * Android.Locations.LocationRequest * Java.Util.Concurrent.IExecutor * Android.Locations.ILocationListener -> unit

Parameters

provider
String

a provider listed by #getAllProviders()

locationRequest
LocationRequest

the location request containing location parameters

executor
IExecutor

the executor handling listener callbacks

listener
ILocationListener

the listener to receive location updates

Attributes

Remarks

Register for location updates from the specified provider, using a LocationRequest, and a callback on the specified Executor.

Only one request can be registered for each unique listener/provider pair, so any subsequent requests with the same provider and listener will overwrite all associated arguments. The same listener may be used across multiple providers with different requests for each provider.

It may take some time to receive the first location update depending on the conditions the device finds itself in. In order to take advantage of cached locations, application may consider using #getLastKnownLocation(String) or #getCurrentLocation(String, LocationRequest, CancellationSignal, Executor, Consumer) instead.

See LocationRequest documentation for an explanation of various request parameters and how they can affect the received locations.

If your application wants to passively observe location updates from all providers, then use the #PASSIVE_PROVIDER. This provider does not turn on or modify active location providers, so you do not need to be as careful about minimum time and minimum distance parameters. However, if your application performs heavy work on a location update (such as network activity) then you should set an explicit fastest interval on your location request in case another application enables a location provider with extremely fast updates.

In case the provider you have selected is disabled, location updates will cease, and a provider availability update will be sent. As soon as the provider is enabled again, another provider availability update will be sent and location updates will resume.

Locations returned from #GPS_PROVIDER are with respect to the primary GNSS antenna position within the device. #getGnssAntennaInfos() may be used to determine the GNSS antenna position with respect to the Android Coordinate System, and convert between them if necessary. This is generally only necessary for high accuracy applications.

When location callbacks are invoked, the system will hold a wakelock on your application's behalf for some period of time, but not indefinitely. If your application requires a long running wakelock within the location callback, you should acquire it yourself.

Spamming location requests is a drain on system resources, and the system has preventative measures in place to ensure that this behavior will never result in more locations than could be achieved with a single location request with an equivalent interval that is left in place the whole time. As part of this amelioration, applications that target Android S and above may receive cached or historical locations through their listener. These locations will never be older than the interval of the location request.

To unregister for location updates, use #removeUpdates(LocationListener).

Java documentation for android.location.LocationManager.requestLocationUpdates(java.lang.String, android.location.LocationRequest, java.util.concurrent.Executor, android.location.LocationListener).

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.

Applies to

RequestLocationUpdates(String, Int64, Single, PendingIntent)

Register for location updates using the named provider, and callbacks delivered via the provided PendingIntent.

[Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;JFLandroid/app/PendingIntent;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLandroid_app_PendingIntent_Handler")]
public virtual void RequestLocationUpdates (string provider, long minTimeMs, float minDistanceM, Android.App.PendingIntent pendingIntent);
[<Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;JFLandroid/app/PendingIntent;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLandroid_app_PendingIntent_Handler")>]
abstract member RequestLocationUpdates : string * int64 * single * Android.App.PendingIntent -> unit
override this.RequestLocationUpdates : string * int64 * single * Android.App.PendingIntent -> unit

Parameters

provider
String

a provider listed by #getAllProviders()

minTimeMs
Int64

minimum time interval between location updates in milliseconds

minDistanceM
Single

minimum distance between location updates in meters

pendingIntent
PendingIntent

the pending intent to send location updates

Attributes

Exceptions

if provider is null or doesn't exist on this device

if intent is null

if no suitable permission is present

Remarks

Register for location updates using the named provider, and callbacks delivered via the provided PendingIntent.

See #requestLocationUpdates(String, LocationRequest, PendingIntent) for more detail on how this method works.

Java documentation for android.location.LocationManager.requestLocationUpdates(java.lang.String, long, float, android.app.PendingIntent).

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.

Applies to

RequestLocationUpdates(String, Int64, Single, ILocationListener)

Register for location updates from the given provider with the given arguments, and a callback on the Looper of the calling thread.

[Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;JFLandroid/location/LocationListener;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLandroid_location_LocationListener_Handler")]
public virtual void RequestLocationUpdates (string provider, long minTimeMs, float minDistanceM, Android.Locations.ILocationListener listener);
[<Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;JFLandroid/location/LocationListener;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLandroid_location_LocationListener_Handler")>]
abstract member RequestLocationUpdates : string * int64 * single * Android.Locations.ILocationListener -> unit
override this.RequestLocationUpdates : string * int64 * single * Android.Locations.ILocationListener -> unit

Parameters

provider
String

a provider listed by #getAllProviders()

minTimeMs
Int64

minimum time interval between location updates in milliseconds

minDistanceM
Single

minimum distance between location updates in meters

listener
ILocationListener

the listener to receive location updates

Attributes

Exceptions

if provider is null or doesn't exist on this device

if listener is null

if the calling thread has no Looper

if no suitable permission is present

Remarks

Register for location updates from the given provider with the given arguments, and a callback on the Looper of the calling thread.

See #requestLocationUpdates(String, LocationRequest, Executor, LocationListener) for more detail on how this method works.

<p class="note"> Prior to Jellybean, the minTime parameter was only a hint, and some location provider implementations ignored it. For Jellybean and onwards however, it is mandatory for Android compatible devices to observe both the minTime and minDistance parameters.

Java documentation for android.location.LocationManager.requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener).

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.

Applies to

RequestLocationUpdates(Int64, Single, Criteria, ILocationListener, Looper)

Register for location updates using a provider selected through the given Criteria, and a callback on the specified Looper.

[Android.Runtime.Register("requestLocationUpdates", "(JFLandroid/location/Criteria;Landroid/location/LocationListener;Landroid/os/Looper;)V", "GetRequestLocationUpdates_JFLandroid_location_Criteria_Landroid_location_LocationListener_Landroid_os_Looper_Handler")]
public virtual void RequestLocationUpdates (long minTimeMs, float minDistanceM, Android.Locations.Criteria criteria, Android.Locations.ILocationListener listener, Android.OS.Looper? looper);
[<Android.Runtime.Register("requestLocationUpdates", "(JFLandroid/location/Criteria;Landroid/location/LocationListener;Landroid/os/Looper;)V", "GetRequestLocationUpdates_JFLandroid_location_Criteria_Landroid_location_LocationListener_Landroid_os_Looper_Handler")>]
abstract member RequestLocationUpdates : int64 * single * Android.Locations.Criteria * Android.Locations.ILocationListener * Android.OS.Looper -> unit
override this.RequestLocationUpdates : int64 * single * Android.Locations.Criteria * Android.Locations.ILocationListener * Android.OS.Looper -> unit

Parameters

minTimeMs
Int64

minimum time interval between location updates in milliseconds

minDistanceM
Single

minimum distance between location updates in meters

criteria
Criteria

contains parameters to choose the appropriate provider for location updates

listener
ILocationListener

the listener to receive location updates

looper
Looper

a Looper object whose message queue will be used to implement the callback mechanism, or null to make callbacks on the calling thread

Attributes

Exceptions

if criteria is null

if listener is null

if no suitable permission is present

Remarks

Register for location updates using a provider selected through the given Criteria, and a callback on the specified Looper.

Note: Since Android KitKat, Criteria requests will always result in using the #FUSED_PROVIDER.

See #requestLocationUpdates(String, LocationRequest, Executor, LocationListener) for more detail on how this method works.

This member is deprecated. Use #requestLocationUpdates(String, long, float, LocationListener, Looper) instead to explicitly select a provider.

Java documentation for android.location.LocationManager.requestLocationUpdates(long, float, android.location.Criteria, android.location.LocationListener, android.os.Looper).

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.

Applies to

RequestLocationUpdates(Int64, Single, Criteria, IExecutor, ILocationListener)

Register for location updates using a provider selected through the given Criteria, and a callback on the specified Executor.

[Android.Runtime.Register("requestLocationUpdates", "(JFLandroid/location/Criteria;Ljava/util/concurrent/Executor;Landroid/location/LocationListener;)V", "GetRequestLocationUpdates_JFLandroid_location_Criteria_Ljava_util_concurrent_Executor_Landroid_location_LocationListener_Handler", ApiSince=30)]
public virtual void RequestLocationUpdates (long minTimeMs, float minDistanceM, Android.Locations.Criteria criteria, Java.Util.Concurrent.IExecutor executor, Android.Locations.ILocationListener listener);
[<Android.Runtime.Register("requestLocationUpdates", "(JFLandroid/location/Criteria;Ljava/util/concurrent/Executor;Landroid/location/LocationListener;)V", "GetRequestLocationUpdates_JFLandroid_location_Criteria_Ljava_util_concurrent_Executor_Landroid_location_LocationListener_Handler", ApiSince=30)>]
abstract member RequestLocationUpdates : int64 * single * Android.Locations.Criteria * Java.Util.Concurrent.IExecutor * Android.Locations.ILocationListener -> unit
override this.RequestLocationUpdates : int64 * single * Android.Locations.Criteria * Java.Util.Concurrent.IExecutor * Android.Locations.ILocationListener -> unit

Parameters

minTimeMs
Int64

minimum time interval between location updates in milliseconds

minDistanceM
Single

minimum distance between location updates in meters

criteria
Criteria

contains parameters to choose the appropriate provider for location updates

executor
IExecutor

the executor handling listener callbacks

listener
ILocationListener

the listener to receive location updates

Attributes

Remarks

Register for location updates using a provider selected through the given Criteria, and a callback on the specified Executor.

Note: Since Android KitKat, Criteria requests will always result in using the #FUSED_PROVIDER.

See #requestLocationUpdates(String, LocationRequest, Executor, LocationListener) for more detail on how this method works.

This member is deprecated. Use #requestLocationUpdates(String, long, float, Executor, LocationListener) instead to explicitly select a provider.

Java documentation for android.location.LocationManager.requestLocationUpdates(long, float, android.location.Criteria, java.util.concurrent.Executor, android.location.LocationListener).

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.

Applies to

RequestLocationUpdates(String, Int64, Single, ILocationListener, Looper)

Register for location updates from the given provider with the given arguments, and a callback on the specified Looper.

[Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;JFLandroid/location/LocationListener;Landroid/os/Looper;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLandroid_location_LocationListener_Landroid_os_Looper_Handler")]
public virtual void RequestLocationUpdates (string provider, long minTimeMs, float minDistanceM, Android.Locations.ILocationListener listener, Android.OS.Looper? looper);
[<Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;JFLandroid/location/LocationListener;Landroid/os/Looper;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLandroid_location_LocationListener_Landroid_os_Looper_Handler")>]
abstract member RequestLocationUpdates : string * int64 * single * Android.Locations.ILocationListener * Android.OS.Looper -> unit
override this.RequestLocationUpdates : string * int64 * single * Android.Locations.ILocationListener * Android.OS.Looper -> unit

Parameters

provider
String

a provider listed by #getAllProviders()

minTimeMs
Int64

minimum time interval between location updates in milliseconds

minDistanceM
Single

minimum distance between location updates in meters

listener
ILocationListener

the listener to receive location updates

looper
Looper

the looper handling listener callbacks, or null to use the looper of the calling thread

Attributes

Exceptions

if provider is null or doesn't exist

if listener is null

if no suitable permission is present

Remarks

Register for location updates from the given provider with the given arguments, and a callback on the specified Looper.

See #requestLocationUpdates(String, LocationRequest, Executor, LocationListener) for more detail on how this method works.

<p class="note">Prior to Jellybean, the minTime parameter was only a hint, and some location provider implementations ignored it. For Jellybean and onwards however, it is mandatory for Android compatible devices to observe both the minTime and minDistance parameters.

Java documentation for android.location.LocationManager.requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener, android.os.Looper).

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.

Applies to

RequestLocationUpdates(String, Int64, Single, IExecutor, ILocationListener)

Register for location updates using the named provider, and a callback on the specified Executor.

[Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;JFLjava/util/concurrent/Executor;Landroid/location/LocationListener;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLjava_util_concurrent_Executor_Landroid_location_LocationListener_Handler", ApiSince=30)]
public virtual void RequestLocationUpdates (string provider, long minTimeMs, float minDistanceM, Java.Util.Concurrent.IExecutor executor, Android.Locations.ILocationListener listener);
[<Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;JFLjava/util/concurrent/Executor;Landroid/location/LocationListener;)V", "GetRequestLocationUpdates_Ljava_lang_String_JFLjava_util_concurrent_Executor_Landroid_location_LocationListener_Handler", ApiSince=30)>]
abstract member RequestLocationUpdates : string * int64 * single * Java.Util.Concurrent.IExecutor * Android.Locations.ILocationListener -> unit
override this.RequestLocationUpdates : string * int64 * single * Java.Util.Concurrent.IExecutor * Android.Locations.ILocationListener -> unit

Parameters

provider
String

a provider listed by #getAllProviders()

minTimeMs
Int64

minimum time interval between location updates in milliseconds

minDistanceM
Single

minimum distance between location updates in meters

executor
IExecutor

the executor handling listener callbacks

listener
ILocationListener

the listener to receive location updates

Attributes

Remarks

Register for location updates using the named provider, and a callback on the specified Executor.

See #requestLocationUpdates(String, LocationRequest, Executor, LocationListener) for more detail on how this method works.

<p class="note">Prior to Jellybean, the minTime parameter was only a hint, and some location provider implementations ignored it. For Jellybean and onwards however, it is mandatory for Android compatible devices to observe both the minTime and minDistance parameters.

Java documentation for android.location.LocationManager.requestLocationUpdates(java.lang.String, long, float, java.util.concurrent.Executor, android.location.LocationListener).

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.

Applies to