Set a mock GPS location on an Android device

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!