问题
I am working on automating some device/server testing we do on various android devices. I need a way to set a specific GPS lat/long on an actual Android device that is usable within a NUnit testing framework. Any help on this will be appreciated.
回答1:
You need to set Allow mock locations true under Developer settings. After that you can write some small utility app which will set mock location on receiving some custom event.
You can then set location using adb shell command e.g
$ adb shell
am start -a android.intent.action.SET_CUSTOM_MOCK_LOCATION -d gps://lat-long
You can receive this information in your utility app and set mock location. Hope this helps
来源:https://stackoverflow.com/questions/25976506/set-a-mock-gps-location-on-an-android-device