1

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?

user924
  • 8,146
  • 7
  • 57
  • 139
  • The exact interval is actually irrelevant. Strictly speaking, you could do it every 10 seconds, but it's much more average in that case. `s = v t`, and you get both time and distance from GPS measurements. Really depends on your use-case though. Also depends on GPS accuracy - at a certain interval, you might not be able to get an accurate measurement, because the GPS can't detect changes that small. Don't have an exact number on when that happens, as it depends on the GPS chip itself (and other factors). You might have to just test and see what works, though – Zoe Feb 18 '21 at 11:05
  • @Zoe well as I said to get real vehicle speed, 10 seconds - during such time vehicle can move or stop a couple of times))) such internal is too big. So I believe Speedometer apps on Google Play use small interval. And of course I know about GPS accuracy but it's not the question here – user924 Feb 18 '21 at 11:10

0 Answers0