androidautocompletegoogle-geocoder

Google Places autocomplete for Android only capturing street


I am working with Google's autocomplete widget for Android, but for some reason it appears to only be capturing the street number and name, but no other part, of the completed address. Here is a screenshot where I entered 91 Hudson Avenue into the autocomplete box:

enter image description here

Here is the snippet of my Java code which obtains the place name from the widget after a place has been selected from the drop down list:

@Override
public void onPlaceSelected(Place place) {
    address = place.getName().toString();
}

The value of address is always 91 Hudson Ave without a city, state, or country, despite that I chose one of the options from the drop down menu. My guess is that there is some silly configuration step which I am missing.

If you want any other information about my setup, let me know and I can edit as soon as I get a chance.


Solution

  • That's because you are doing this:

    address = place.getName().toString();
    

    You should be doing this:

    address = place.getAddress().toString();
    

    enter image description here