Right now I have such settings for location updates:
private const val LOCATION_MIN_TIME_INTERVAL = 200L
private val locationRequest = LocationRequest().apply {
interval = LOCATION_MIN_TIME_INTERVAL
fastestInterval = LOCATION_MIN_TIME_INTERVAL / 2
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
}
override fun onLocationResult(locationResult: LocationResult?) {
super.onLocationResult(locationResult)
val speed = locationResult?.lastLocation?.speed
}
Of course it may drain the battery much faster if using 200 milliseconds but I believe that to get current vehicle speed in real time (in KM/H or MPH units for example) requires such interval, so it should be appropriate for such case, isn't?