DeviceLocationProvider

location provider specialisation that provides real-time locations generated from the device

Functions

Link copied to clipboard
abstract fun addLocationObserver(observer: LocationObserver)

Registers an observer in this instance of LocationProvider. One instance of LocationProvider can have more than one observer. It is expected that LocationProvider will not start until an observer is added. The observer registered will receive notifications on the same looper as the one where this method is invoked. If the looper is not available, this method can be called from any thread.

abstract fun addLocationObserver(observer: LocationObserver, looper: Looper)

Registers an observer in this instance of the client. One instance of the client can have more than one observer. It is expected that the client will not start until an observer is added.

Link copied to clipboard

Gets the last known location. This call will never activate hardware to obtain a new location, and will only return a cached location. Note, that the returned location may be quite old, so the timestamp of the location should always be checked.

Link copied to clipboard
open fun getName(): String?
Link copied to clipboard

Removes the observer from this instance of LocationProvider. If the observer is not registered, this is no-op. It is expected that if there are no observers, the LocationProvider will stop automatically.

Link copied to clipboard
abstract fun removeLocationUpdates(pendingIntent: PendingIntent)

Removes location updates for the given pending intent. It is recommended to remove location requests when the activity is in a paused or stopped state, doing so helps reducing battery consumption.

Link copied to clipboard
@RequiresPermission(anyOf = ["android.permission.ACCESS_COARSE_LOCATION", "android.permission.ACCESS_FINE_LOCATION"])
abstract fun requestLocationUpdates(pendingIntent: PendingIntent)

Register for location updates to be delivered via the provided PendingIntent.