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

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

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


当前回答

如果上述解决方案不奏效。试试这个:

在你的android manifest .xml中,在应用程序标记之外添加以下两个链接,当然是在你的manifest标记中

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" ></uses-permission>
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>

其他回答

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.

我试图通过adb为许多点设置地理定位,但无法让我的应用程序看到任何GPS数据。但当我尝试打开DDMS时,选择我的应用程序的进程并通过模拟器控制选项卡发送坐标,它马上就工作了。

在Mac、Linux或Cygwin系统下:

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

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

首先进入eclipse中的DDMS部分 比打开模拟器控件.... 转到手动部分 设置纬度和长度,然后按发送按钮

如果您正在使用Eclipse,请转到窗口->打开透视图->DDMS,然后在位置控制中键入1并单击发送。