Forum Discussion

vatbub's avatar
vatbub
Contributor
9 years ago
Solved

Set Mock location on Android

Hey guys,

Similar to the scenario in this forum topic, we want to do geolocation testing for our apps, so we use the code from this help article to set a mock location.

 

While with iOS we have problems discussed in the topic linked above, in Android we experience the following:

  1. We run the test where the mock location is set and it runs with no error but the Android device still shows its physical GPS location.
  2. We run the test a second time with different fake coordinates and this time the Android device shows the fake coordinates from the first run.

So I guess it's a problem with refreshing the GPS info on the device. According to the Note in the help article linked above saying

 

"Location data are retrieved upon initializing the GPSData object. Once created, the GPSData object stores the values that were actual at that moment. To update the location coordinates, you need to re-initialize the GPSData object by re-reading the GPS.Location property. "

 

we just post the coordinates once more to the log.

 

In the Log, the coordinates seem to be updated correctly, it's just the device not showing the correct fake position.

 

We also tried to make the script call itself at the end (while avoiding an endless loop) but it ended up in the device finding no GPS at all.

Thanks for helping again,

Greetings,

vat