I am using Location Manager
for getting the current longitude and latitude, but in an emulator I am getting an error. How do I get locations on emulator?
This is my code:
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);
}