I'm working on testing an app right now that relies on location to update content presented to the user, and I'm having an issue with the results when running in the android emulator. If I set the emulator's location, the initial request to FusedLocationProvider for latest location (getLastLocation
) gives the correct response, and indeed requestLocationUpdates
will trigger at least 1 location as well.
However, if I then manually change the location of the emulator, the requestLocationUpdates
listener is never provided with the new location. I know that the device is registering the change, because if I open google maps on the emulator the google maps location will update to the new location; and indeed, if I then switch back to my app, the requestLocationUpdates
listener will then be triggered with the new location.
Note that I am using a LocationRequest
with Priority.PRIORITY_HIGH_ACCURACY
and setDurationMillis(15000)
.
Can anyone tell me if this is a known issue with the android emulators, or is there a bug in my code causing the problem behaviour? I unfortunately do not have a contemporary real android device to test on at present.
Build/Emulator/Env Details:
compileSdkVersion: 33
minSdkVersion: 20
targetSdkVersion: 33
Pixel 5 Android 13.0 Google APIs x86_64
Android Studio 2022.1.1 Patch 1
gradle-7.5