Here I am using this code in order to get the latitude and longitude of the location but all that I am getting is latitude 0.0 and longitude 0.0 the code to find the latitude and logitude that I am using is given as below , Also I am testing this code in Genymotion emulator and all that is printed in the log is 0.0 0.0 because the if(address.size()>0) is not getting satisfyied can anyone tell where am I going wrong or is it because of emulator.
Geocoder geo = new Geocoder(getActivity());
try {
List<Address> address = geo.getFromLocationName(str_ELocation,1);
if (address.size() > 0) {
Log.d("List Size : ", "" + address.size());
latitude = address.get(0).getLatitude();
longitude = address.get(0).getLongitude();
} else {
Log.d("In Else", "In Else");
}
} catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
Log.d("LONGITUDE AND LATITUDE", "" + longitude + "" + latitude);
Also is there any other simpler solution to just find latitude and longitude. I am using this in Fragment and so I am using getActivity() here instead of myClassName.this.