I try to implement reverse geocoding in Android App. But when I call getFromLocation() function, it doesn't return value. Can Someone see my code and tell me where I might make mistakes?
public void getAddress(Location location) {
Geocoder geo_coder = new Geocoder(this, Locale.ENGLISH);
try {
List<Address> address = geo_coder.getFromLocation(location.getLatitude(),
location.getLongitude(), 1);
Toast.makeText(this, Double.toString(location.getLongitude()), Toast.LENGTH_LONG).show();
Toast.makeText(this, Double.toString(location.getLatitude()), Toast.LENGTH_LONG).show();
if (address != null && address.size() > 0) {
textAddr.setText(address.get(0).getFeatureName() + ", " +
address.get(0).getLocality() + ", " + address.get(0).getAdminArea() +
", " + address.get(0).getCountryName());
}
else {
textAddr.setText("Waiting for Location!");
}
}
catch (IOException e) {
e.printStackTrace();
}
}
The toast can show the right latitude and longitude, but I can't get the real address