I am using this post : What is the simplest and most robust way to get the user's current location on Android? to obtain the device's current location. And my code is :
locationResult = new LocationResult() {
@Override
public void gotLocation(Location location) {
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
};
myLocation = new MyLocation();
myLocation.getLocation(this, locationResult);
mapController = mapView.getController();
point = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));
mapController.animateTo(point);
Toast.makeText(getApplicationContext(), ("Latitude = "+latitude+" Longitude = "+longitude), Toast.LENGTH_SHORT).show();
mapController.setZoom(17);
mapView.invalidate();
latitude & longitude is declared as global double type variable. But , after running the application I am getting blue screen. I think , the problem is my code is not capable of getting the value of latitude & longitude . Can anybody please help me ? Thanks .