How to add more than two TypeFilter to FindAutocompletePredictionsRequest?

Viewed 1116

I'm migrating to new google places sdk client and I want to set more than 2 filter to FindAutocompletePredictionsRequest but I can not find the solution

var autoCompleteRequest = FindAutocompletePredictionsRequest.builder().setLocationBias(
            bounds).setCountry("TR").setQuery(query).setSessionToken(
            AutocompleteSessionToken.newInstance()).setTypeFilter(ADDRESS).build()

As you can see I can only set one filter also I want to set ADDRESS and ESTABLISHMENT together, I tried to set list of filter but doesn't work

sdk version

implementation 'com.google.android.libraries.places:places:1.1.0'
2 Answers

You can just remove setTypeFilter and by default it works with both.

 val request = FindAutocompletePredictionsRequest.builder()
        .setCountry(country)
        .setSessionToken(token)
        .setQuery(constraint.toString())
        .build()

You can use a binary mask like:

.setTypeFilter(TYPE_FILTER_CITIES|TYPE_FILTER_ADDRESS)
Related