FusedLocationProvider

A location provider backed by Google Play Services fused location.

Each collection requests fused updates, emits the last location when one exists, and removes its callback when collection ends.

LocationAccuracy.BestForNavigation and LocationAccuracy.High map to Priority.PRIORITY_HIGH_ACCURACY, LocationAccuracy.Balanced maps to Priority.PRIORITY_BALANCED_POWER_ACCURACY, LocationAccuracy.Low maps to Priority.PRIORITY_LOW_POWER, and LocationAccuracy.Lowest maps to Priority.PRIORITY_PASSIVE.

LocationAvailability.isLocationAvailable equal to false maps to LocationUnavailableReason.TemporarilyUnavailable. A SecurityException maps to LocationUnavailableReason.PermissionDenied. Other exceptions escape the flow, and the collector classifies them as LocationUnavailableReason.UnexpectedFailure.

The Context constructor delegates permission and requestPermission to an AndroidLocationProvider. The FusedLocationProviderClient constructor keeps the default LocationProvider.permission, which is always granted, and its updates still surface a SecurityException as LocationUnavailableReason.PermissionDenied.

Constructors

Link copied to clipboard
constructor(locationClient: FusedLocationProviderClient)

Creates a provider backed by locationClient.

constructor(context: Context)

Creates a provider with its own fused client and an AndroidLocationProvider as its permission delegate.

Properties

Link copied to clipboard
open override val backendId: String
Link copied to clipboard
open override val permission: StateFlow<LocationPermission>

Functions

Link copied to clipboard
open override fun requestPermission()
Link copied to clipboard
@RequiresPermission(anyOf = ["android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"])
open override fun updates(request: LocationRequest): Flow<LocationEvent>