mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
chore: update play-services-location to 21.0.1
This commit is contained in:
parent
fae444b9a1
commit
5abf141033
2 changed files with 11 additions and 9 deletions
|
|
@ -12,6 +12,7 @@ import com.google.android.gms.location.LocationCallback
|
|||
import com.google.android.gms.location.LocationRequest
|
||||
import com.google.android.gms.location.LocationResult
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.google.android.gms.location.Priority
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
|
@ -39,20 +40,21 @@ class SharedLocationManager constructor(
|
|||
|
||||
// Set up the Fused Location Provider and LocationRequest
|
||||
private val fusedLocationClient = LocationServices.getFusedLocationProviderClient(context)
|
||||
private val locationRequest = LocationRequest.create().apply {
|
||||
interval = desiredInterval
|
||||
fastestInterval = 30 * 1000L
|
||||
maxWaitTime = 5 * 60 * 1000L
|
||||
// smallestDisplacement = 30F // 30 meters
|
||||
priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY
|
||||
}
|
||||
private val locationRequest = LocationRequest.Builder(desiredInterval)
|
||||
.setMinUpdateIntervalMillis(30 * 1000L)
|
||||
.setMaxUpdateDelayMillis(5 * 60 * 1000L)
|
||||
// .setMinUpdateDistanceMeters(30f) // 30 meters
|
||||
.setPriority(Priority.PRIORITY_BALANCED_POWER_ACCURACY)
|
||||
.build()
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private val _locationUpdates = callbackFlow {
|
||||
val callback = object : LocationCallback() {
|
||||
override fun onLocationResult(result: LocationResult) {
|
||||
// info("New location: ${result.lastLocation}")
|
||||
trySend(result.lastLocation)
|
||||
result.lastLocation?.let { lastLocation ->
|
||||
trySend(lastLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!context.hasBackgroundPermission() || !isGooglePlayAvailable(context)) close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue