Location.getCurrentPositionAsync is very slow on Android (only)?

Hi, I’m using Location.getCurrentPositionAsync but it seems to take several seconds on Android whereas it’s fine on iOS. Is there anything I can do about it?

  try {
    const location = await Location.getCurrentPositionAsync({
      timeout: 1000, // 1 second
      // I've tried all the different accuracies it doesn't seem to make much difference
      accuracy: Location.Accuracy.Balanced 
    });
    return { lat: location.coords.latitude, lng: location.coords.longitude };
  } catch (err) {
    console.log(`Unable to get location ${err.message}`);
    return { lat: 0, lng: 0};
  }

I’ve put in the timeout because otherwise it makes the app seem really slow when you press on a button and nothing happens for several seconds. In fact now I cache the location for 5 minutes so I can return it if the real thing times out, but it’s not ideal :frowning:

Thanks!

Hey @jumptech, what device(s) are you testing it with on Android? Also, what SDK version are you using?

Cheers,
Adam

Hi, I’m testing on a Samsung Galaxy Tab 3 and a OnePlus 5, using SDK 33 (just about to update to 34, probably next week).

My colleagues have tested on a variety of other Android devices.

In the end I’ve had to pre-emptively fetch the GPS location and then cache it so I’ve got one that’s approximately right, but it rather defeats the object of being able to get the location.

On the OnePlus5 just now it takes between 2-10 seconds to get the location.

Thanks!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.