Android how to get the street name from an address returned by Geocoder

Jorge Gil picture Jorge Gil · Sep 14, 2012 · Viewed 15.9k times · Source

I'm using Geocoder in reverse way to get an address from a given lat & lon.

Do you know how to get from Address only the street name?

    Geocoder geocoder = new Geocoder(AutoFinderMapActivity.this);
    try {
        List<Address> addressList = geocoder.getFromLocation(latitude, longitude, 1);
        if (addressList != null && addressList.size() > 0) {
            // Help here to get only the street name
            String adress = addressList.get(0).get...;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

Thanks in advance,

Answer

joe_developer picture joe_developer · Mar 3, 2013

I was searching up the very same thing. I disagree with the answer that was marked as correct. I could be wrong but it would appear that "Thoroughfare" (what a quaint old English term!) is the field that provides the street name. so for example:

get the addresses:

    List<Address> addresses = null;
    addresses = geocoder.getFromLocation(latitude, longitude,1);
    if(addresses != null && addresses.size() > 0 ){
       Address address = addresses.get(0);
       // Thoroughfare seems to be the street name without numbers
            String street = address.getThoroughfare();
    }