Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 397
Tim Biegeleisen Avatar asked Nov 30 '25 07:11

Tim Biegeleisen


1 Answers

That's because you are doing this:

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

You should be doing this:

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

enter image description here

like image 110
Pavya Avatar answered Dec 02 '25 21:12

Pavya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!