我想在Android模拟器中获得经度和纬度进行测试。
有谁能指导我如何实现这个目标吗?
如何将模拟器的位置设置为测试位置?
我想在Android模拟器中获得经度和纬度进行测试。
有谁能指导我如何实现这个目标吗?
如何将模拟器的位置设置为测试位置?
当前回答
Dalvik Debug Monitor >选择模拟器>模拟器控制选项卡>位置控制。
DDMS——android_sdk/tools/ DDMS或android_sdk/tools/monitor
其他回答
如果您正在使用Eclipse,请转到窗口->打开透视图->DDMS,然后在位置控制中键入1并单击发送。
首先进入eclipse中的DDMS部分 比打开模拟器控件.... 转到手动部分 设置纬度和长度,然后按发送按钮
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.
如果你正在使用eclipse,然后使用模拟器控制器,你可以手动设置纬度和经度,并在模拟器中运行基于地图的应用程序
假设你已经设置并运行了mapview:
MapView mapView = (MapView) findViewById(R.id.mapview);
final MyLocationOverlay myLocation = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(myLocation);
myLocation.enableMyLocation();
myLocation.runOnFirstFix(new Runnable() {
public void run() {
GeoPoint pt = myLocation.getMyLocation();
}
});
您需要在清单中获得以下许可:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
要从Eclipse向模拟器发送模拟坐标,请转到“窗口”菜单,选择“显示视图”>“其他”>“模拟器控件”,您可以从出现的模拟器控制窗格中发送坐标。