Google Places Autocomplete Services using Google Places API

Google Places Autocomplete Services uses Google Place API and it returns predetermine user search queries. In the last tutorial we learn about Android show current location in Google Map using Google Maps Android API. In this tutorial we will learn about how to use Google Place Autocomplete Services using Google Places API in Google Map. First of all we have to create a project on  Google APIs Dashboard  you can check previous tutorial to set up a project and get an API key. We will follow two approach to  create Google Place Autocomplete Services using Google Places API.

  1. Place Autocomplete using PlaceAutocompleteFragment:We use a fragment to choose autocomplete to show place name and a TextView to show selected place details. The layout file of this activity is given below.

  • PlaceAutocompleteFragment show the autocomplete list in a fragment and PlaceSelectionListener handles the user selected place from the list.

Demo:
2.Place Autocomplete using Intent: We use an  intent to launch Autocomplete Activity  and receive the selected place in desired activity. We have used a Button to launch an activity and a TextView to show the details of selected place. The layout file of this activity is given below.

  • We have used an intent  PlaceAutocomplete.IntentBuilder to launch activity in full screen mode.
  • We are passing an intent and unique integer request code to startActivityForResult() method.
  • onActivityResult recieve the result from autocomplete activity.

Demo:

 

This is about Google Place Autocomplete services in Android. You can check other tutorials as well. If you have any doubt or facing any problems let me know in comment box. You can check other tutorials as well.

Youtube channel integration in Android using YoutubePlayerView API

Parse JSON data into Spinner in Android

Android Login and Signup with PHP MySQL