
Getting place predictions programmatically Super.onActivityResult(requestCode, resultCode, data) Val status = Autocomplete.getStatusFromIntent(data) Set up a PlaceSelectionListener to handle the response.ĪtOnPlaceSelectedListener(new PlaceSelectionListener() void Place place) ") Specify the types of place data to return.ĪtPlaceFields(Arrays.asList(, )) GetSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment) Initialize the AutocompleteSupportFragment.ĪutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)
The following code shows creating a reference to theįragment and adding a listener to your AutocompleteSupportFragment: The PlaceSelectionListener handles returning a place in response to the You must call super.onActivityResult, otherwise the fragment will notĪdd a PlaceSelectionListener to an activity
If you are using the Autocomplete fragment, and need to override onActivityResult,. To provide aĬonsistent visual appearance, nest the fragment within another layout element By default, the fragment has no border or background. To add AutocompleteSupportFragment to an activity, add a new fragment to an Add a listener to your activity or fragment.Īdd AutocompleteSupportFragment to an activity. Add a fragment to your activity's XML layout. To add an AutocompleteSupportFragment to your app, take the following steps: Option 1: Embed an AutocompleteSupportFragment Option 2: Use an intent to launch the autocomplete activity. Option 1: Embed an AutocompleteSupportFragment. There are two options for adding the autocomplete widget to your app: Instance is returned, which your app can then use to get As a user enters search terms, the widget presents a The autocomplete widget is a search dialog with built-in autocompleteįunctionality. Get place predictions programmatically to create a customized user. Time and ensure a consistent user experience. Add an autocomplete widget to save development. You can add autocomplete to your app in the following ways: As the user types, theĪutocomplete service returns suggestions for places such as businesses, Predictions in response to user search queries. The autocomplete service in the Places SDK for Android returns place Select platform: Android iOS JavaScript Web Service
Prepare for Google Play data disclosure requirements.