1

Previously in my app I have been using PRIORITY_HIGH_ACCURACY for FusedLocationProviderClient:

private fun getLocationRequest(): LocationRequest =
    LocationRequest.Builder(prefsManager.getLocationFrequency).apply {
        setMinUpdateIntervalMillis(prefsManager.getLocationFrequency / 2)
        setPriority(
           Priority.PRIORITY_HIGH_ACCURACY
        )
    }.build()

fusedLocationClient.requestLocationUpdates(
    getLocationRequest(),
    this,
    backgroundThread.looper
)

And it was working fine.

Then I decided to set it as PRIORITY_BALANCED_POWER_ACCURACY by default and give users an option to control it:

private fun getLocationRequest(): LocationRequest =
    LocationRequest.Builder(prefsManager.getLocationFrequency).apply {
        setMinUpdateIntervalMillis(prefsManager.getLocationFrequency / 2)
        setPriority(
            when (prefsManager.gpsMode) {
                GpsPrioroty.Balanced -> {
                    Priority.PRIORITY_BALANCED_POWER_ACCURACY
                }
                GpsPrioroty.Accuracy -> {
                    Priority.PRIORITY_HIGH_ACCURACY
                }
                else -> {
                    Priority.PRIORITY_LOW_POWER
                }
            }
        )
    }.build()

But not the app can't find any satellites at all, even coordinates from network source.

Tested on Samsung S22 Ultra, and one user with Samsung Galaxy S10e reported it as well.

If you change the option to PRIORITY_HIGH_ACCURACY in the settings then it works fine.

What's wrong here?

p.s. getLocationFrequency by default is 0.5 seconds (500)

user924
  • 8,146
  • 7
  • 57
  • 139

0 Answers0