I used reverse geocoding from Google Maps to get an address, and the first time it worked, put the address completely, but now it just shows me latitude and longitude, no name, in any address.
Can someone help me?
My code:
private class GetAddressTask extends AsyncTask<Location, Void, String> {
@Override
protected String doInBackground(Location... params) {
Geocoder geocoder = new Geocoder(MainActivity.this);
Location loc = params[0];
List<Address> addresses = null;
try {
addresses = geocoder.getFromLocation(loc.getLatitude(), loc.getLongitude(), 1);
} catch (IOException e) {
return null;
}
if( addresses != null && addresses.size() > 0 ) {
Address addr = addresses.get(0);
String addressText = addr.getAddressLine(0);
updateLastStreet(addressText, MainActivity.this);
return addressText;
}
return null;
}
}