我想在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.

对于Android Studio用户:

运行模拟器,

然后进入“工具->Android ->Android设备监视器”

打开模拟器控件选项卡,并使用位置控件组。

如果你正在使用eclipse,然后使用模拟器控制器,你可以手动设置纬度和经度,并在模拟器中运行基于地图的应用程序

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

你可以使用像genymotion这样的模拟器,它可以让你灵活地模拟当前的GPS位置等。