LocationHelper
Centralized location helper based on Google Play Services FusedLocationProviderClient.
This utility provides high-level APIs for fetching the last known location, getting a single fresh fix, or observing a continuous stream of updates.
Requirements:
Google Play Services dependency in
android/build.gradle.ktsPermissions:
ACCESS_FINE_LOCATIONorACCESS_COARSE_LOCATION
Example usage:
val locationHelper = LocationHelper(context)
// Get last known location (fast, can be null)
val last = locationHelper.getLastLocation()
// Get single fresh fix
val location = locationHelper.getCurrentLocation(LocationConfig.HighAccuracy)
// Continuous stream
viewModelScope.launch {
locationHelper.locationFlow(LocationConfig.Balanced).collect { location ->
updateMap(location)
}
}Content copied to clipboard
Functions
Link copied to clipboard
@RequiresPermission(anyOf = ["android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"] )
Link copied to clipboard
@RequiresPermission(anyOf = ["android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"] )
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@RequiresPermission(anyOf = ["android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"] )