我Location Manager
用于获取当前的经度和纬度,但在模拟器中出现错误。如何在模拟器上获取位置?
这是我的代码:
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);
}