Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Android Places API AutocompleteFilter

I am trying to implement the new Places API for android in my app and I cant seem to figure out how to set a filter to the request. Here is my code.

LatLng southWest = new LatLng(85, -180);
LatLng northEast = new LatLng(-85, 180);
LatLngBounds bounds = new LatLngBounds(southWest, northEast);
AutocompleteFilter filter = AutocompleteFilter.create(WHAT SHOULD GO HERE?);
PendingResult result = Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient,
            search.getText().toString(), bounds, filter);

As you can see I followed the documentation provided by google here but I they dont talk about how to implement the filter, after reading the API Reference I still cant figure out how to implement the API.

I need help figuring out what should go in as the parameter for AutocompleteFilter.create() for the API. I want to filter the data by cities

Thanks

like image 899
TanmayP Avatar asked Apr 30 '15 21:04

TanmayP


1 Answers

It works on Google Play Service 9.4.

AutocompleteFilter filter = new AutocompleteFilter.Builder()
        .setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
        .build();
like image 174
Andy Cheng Avatar answered Oct 14 '22 19:10

Andy Cheng