我想在Android模拟器中获得经度和纬度进行测试。
有谁能指导我如何实现这个目标吗?
如何将模拟器的位置设置为测试位置?
我想在Android模拟器中获得经度和纬度进行测试。
有谁能指导我如何实现这个目标吗?
如何将模拟器的位置设置为测试位置?
当前回答
在模拟中选择扩展控件。之后,您可以通过搜索或拖动映射到要设置的位置来设置模拟的位置。
最后点击SET LOCATION按钮保存。
其他回答
The already mentioned multiple times answer to use the shell command "geo fix..." is the correct answer. But in case you use LocationClient.getLastLocation() to retrieve your data it is worth to mention that it will not work at first. The LocationClient class uses the Google Play Service to retrieve the coordinates. For me this started working after running the emulators maps app once. During the first start you are asked to allow google apps access to your location, which I guess does the trick.
把阿尔贝托·高纳的回答写在一行里
token=$(cat ~/.emulator_console_auth_token); cat <(echo -e "auth $token \n geo fix 96.0290791 16.9041016 \n exit") - | nc localhost 5554
5554是adb设备中显示的模拟器端口号。
如果亚行的emu能够发挥作用,情况会更好。
在我自己的一个项目中,我开发了一个在线服务,可以为Android模拟器提供模拟位置。
它使用geo nmea而不是geo fix,这使得它可以设置速度,航线,精确的时间等,除了纬度/长度。
该服务只需要nc (netcat)命令行工具,不需要其他工具。
http://www.kisstech.ch/nmea/
Dalvik Debug Monitor >选择模拟器>模拟器控制选项卡>位置控制。
DDMS——android_sdk/tools/ DDMS或android_sdk/tools/monitor
对于BlueStack用户:打开模拟器,按Ctrl+Shift +K,然后找到你的位置,并按下设置位置!