我想在Android模拟器中获得经度和纬度进行测试。

有谁能指导我如何实现这个目标吗?

如何将模拟器的位置设置为测试位置?


当前回答

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.

其他回答

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.

在Linux系统中,通信端口被阻塞。导航终端到android SDK中的platform-tools文件夹,并启动以下命令:

./adb -s #{device_name} emu geo fix #{longitude} #{latitude}

在eclipse中:

您可能需要向下拖动DDMS窗口。 “Location Controls”位于“Telephony Actions”下,可能会被一个正常大小的控制台视图隐藏(控制台,LogCat等栏可能会覆盖它!)

~

在Mac、Linux或Cygwin系统下:

echo 'geo fix -99.133333 19.43333 2202' | nc localhost 5554

这样你就能到墨西哥城了。相应地改变你的经度/纬度/高度。如果你对nmea不感兴趣,这应该足够了。

请参见获取用户位置

请参阅提供模拟位置数据。你会找到解决方法的。