Autocomplete.IntentBuilder

public class Autocomplete.IntentBuilder


Builder for an intent to launch the autocomplete activity.

Summary

Public constructors

IntentBuilder(
    AutocompleteActivityMode mode,
    List<Place.Field> placeFields
)

Creates a new builder for an intent to launch the autocomplete activity.

Public methods

Intent
build(Context context)
Autocomplete.IntentBuilder
setCountries(String[] countries)

See setCountries.

Autocomplete.IntentBuilder
setCountries(List<String> countries)

Sets countries to restrict results to.

Autocomplete.IntentBuilder

This method is deprecated.

Use setCountries instead.

Autocomplete.IntentBuilder

Sets the hint text to display in the search input field when there is no text entered.

Autocomplete.IntentBuilder

Sets the initial query in the search input.

Autocomplete.IntentBuilder

Biases the autocomplete results to a particular area.

Autocomplete.IntentBuilder
setLocationRestriction(
    @Nullable LocationRestriction locationRestriction
)

Restricts the autocomplete results to a particular area.

Autocomplete.IntentBuilder

Sets the unicode country/region code (CLDR) of the location where the request is coming from.

Autocomplete.IntentBuilder

This method is deprecated.

Use setTypesFilter.

Autocomplete.IntentBuilder
setTypesFilter(List<String> placeTypes)

Sets the filter that restricts the type(s) of results returned from the response

Public constructors

IntentBuilder

public IntentBuilder(
    AutocompleteActivityMode mode,
    List<Place.Field> placeFields
)

Creates a new builder for an intent to launch the autocomplete activity.

Parameters
AutocompleteActivityMode mode

the display mode of the autocomplete activity.

List<Place.Field> placeFields

the fields of the place to be requested. See Place.Field for the specifiable fields. Read more about Place Data Fields.

Public methods

build

public Intent build(Context context)

setCountries

public Autocomplete.IntentBuilder setCountries(String[] countries)

See setCountries.

setCountries

public Autocomplete.IntentBuilder setCountries(List<String> countries)

Sets countries to restrict results to.

This must be a list of ISO 3166-1 Alpha-2 country codes (case insensitive). If no countries are set, no country filtering will take place.

This will override values set with setCountry.

Up to five countries are supported. See the components parameter here.

setCountry

public Autocomplete.IntentBuilder setCountry(@Nullable String country)

See setCountries for details.

This will override countries set with setCountries.

setHint

public Autocomplete.IntentBuilder setHint(@Nullable String hint)

Sets the hint text to display in the search input field when there is no text entered.

If the hint is unset or explicitly set to null, the hint text will be set to the default value.

setInitialQuery

public Autocomplete.IntentBuilder setInitialQuery(@Nullable String initialQuery)

Sets the initial query in the search input.

setLocationBias

public Autocomplete.IntentBuilder setLocationBias(@Nullable LocationBias locationBias)

Biases the autocomplete results to a particular area.

If the bounds are unset or explicitly set to null, the autocomplete results will be biased to the device's approximate location.

setLocationRestriction

public Autocomplete.IntentBuilder setLocationRestriction(
    @Nullable LocationRestriction locationRestriction
)

Restricts the autocomplete results to a particular area.

setRegionCode

public Autocomplete.IntentBuilder setRegionCode(@Nullable String regionCode)

Sets the unicode country/region code (CLDR) of the location where the request is coming from.

The region code field is only supported by Places API (New). Please enable your API key for the Places API (New) in the Google Cloud Console to use region code. If you do not enable your API key for the Places API (New), the region code will not affect the results.

setTypeFilter

public Autocomplete.IntentBuilder setTypeFilter(@Nullable TypeFilter typeFilter)

Filters the autocomplete results to the given place type.

setTypesFilter

public Autocomplete.IntentBuilder setTypesFilter(List<String> placeTypes)

Sets the filter that restricts the type(s) of results returned from the response

Up to 5 place types are supported. A comprehensive list of the supported types can be found in com.google.android.libraries.places.api.model.PlaceTypes. The type collections specified in table 3 must be passed in as solo entries and cannot be combined with any other entries from table 1 or 2.

This will override setTypeFilter if both are used.