android emulator中的动态地理位置更新?
我正在使用android emulator中的动态地理位置更新?,android,android-emulator,Android,Android Emulator,我正在使用位置管理器获取当前经度和纬度,但在模拟器中我得到了一个错误。如何在emulator上获取位置 这是我的代码: lm = (LocationManager) context .getSystemService(Context.LOCATION_SERVICE); android.location.Location currentLocation = lm .getLastKnownLocation(LocationManager.NETWORK_PROVIDER)
位置管理器
获取当前经度和纬度,但在模拟器中我得到了一个错误。如何在emulator上获取位置
这是我的代码:
lm = (LocationManager) context
.getSystemService(Context.LOCATION_SERVICE);
android.location.Location currentLocation = lm
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (currentLocation == null)
currentLocation = lm
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (currentLocation != null) {
currentLongitude = currentLocation.getLongitude();
currentLatitude = currentLocation.getLatitude();
// Get last location of driver
lastLongitude = Double.valueOf(app.GetLongitude(context));
lastLatitude = Double.valueOf(app.GetLatitude(context));
distance = CommonFunctions.GetDistance(currentLongitude,
currentLatitude, lastLongitude, lastLatitude);
}
在Eclipse中打开Emulator控件并设置lat和long-in-Location控件有关详细解释的答案,您可以在此处查看: 在这篇文章中,它解释了如何处理这个问题
希望这有帮助 首先必须打开emulator控件视图(窗口->showView->其他->emulator控件)。 然后,当应用程序启动时,在模拟器控件中的位置控件处,
设置一个位置并单击send按钮,您将在Eclipse的DDMS透视图中找到此窗口。通过这种方式,您可以使用各种位置值测试应用程序 按照以下步骤设置模拟值: 转到EclipseDDMS透视图,通过 Windows>打开透视图>其他>DDMS(您可以键入以筛选列表) 查找仿真器控件选项卡 然后在位置控制箱内 您可以将lat、long发送到emulator以模拟gps变化 如果找不到Emulator控件,请通过以下方式打开它:
Windows>显示视图>其他>仿真器控件(您可以键入以筛选列表)您遇到了哪个错误??张贴日志。。