LocationManager
Streams device location updates and exposes the last known Location.
Create a LocationManager via createLocationManager, or with rememberLocationManager in Compose. For an API that handles permissions and subscriptions automatically in Compose, use rememberLocation. A LocationManager stops updating when it is closed.
val manager = createLocationManager(LocationManagerOptions(accuracy = LocationAccuracy.HIGH))
if (manager.requestLocationPermission()) {
manager.addOnLocationChangedListener { location -> println("At ${location.latitude}, ${location.longitude}") }
manager.startUpdating()
}Content copied to clipboard
See also
Properties
Link copied to clipboard
The last known Location, or null if no location is known.
Link copied to clipboard
The current location permission status.
Functions
Link copied to clipboard
abstract fun addOnLocationChangedListener(callback: (location: Location) -> Unit): ListenerSubscription
Link copied to clipboard
Requests the location permission.
Link copied to clipboard
Starts location updates.
Link copied to clipboard
Stops location updates.