我使用Location Manager
獲取當前的經度和緯度,但在模擬器中出現錯誤。如何在仿真器上獲取位置?Android模擬器中的動態地理位置更新?
這是我的代碼:
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);
}
您遇到錯誤?發佈logcat .. – Lokesh