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);
}
You’ll find this window in the DDMS perspective in Eclipse. This way you can test your application with various location values.
Follow below steps to set mock values:
go to eclipse DDMS perspective,Via
Windows>Open Perspective > other > DDMS (You can type to filter the list)
find Emulator Control tab
then inside Location Control box
You can send lat, long to emulator to simulate gps changes.
if you cannot find Emulator Control, just open it via:
Windows > show view > other > Emulator Control (You can type to filter the list)