You're all set!

To start developing, please head over to our developer documentation.

Activate the Google Places API for Android

To get you started we'll guide you through the Google Developers Console to do a few things first:

  1. Create or choose a project
  2. Activate the Google Places API for Android
  3. Create appropriate keys
Continue

Place IDs and Details

The Google Places API for Android provides your app with rich information about places, including the place's name and address, the geographical location specified as latitude/longitude coordinates, the type of place (such as night club, pet store, museum), and more. To access this information for a specific place, you can use the place ID, a stable identifier that uniquely identifies a place.

  1. Place details
  2. Get a place by ID
  3. Display attributions in your app
  4. More about place IDs

Place details

The Place object provides information about a specific place. You can get hold of a Place object in the following ways:

Use the following methods to retrieve data from a Place:

  • getName() – The place's name.
  • getAddress() – The place's address, in human-readable format.
  • getID() – The textual identifier for the place. Read more about place IDs in the rest of this page.
  • getPhoneNumber() – The place's phone number.
  • getWebsiteUri() – The URI of the place's website, if known. This is the website maintained by the business or other entity associated with the place. Returns null if no website is known.
  • getLatLng() – The geographical location of the place, specified as latitude and longitude coordinates.
  • getViewport() – A viewport, returned as a LatLngBounds object, useful for displaying the place on a map. May return null if the size of the place is not known.
  • getLocale() – The locale for which the name and address are localized.
  • getPlaceTypes() – A list of place types that characterize this place. For a list of available place types, see the documentation for the Place interface.
  • getPriceLevel() – The price level for this place, returned as an integer with values ranging from 0 (cheapest) to 4 (most expensive).
  • getRating() – An aggregated rating of the place, returned as a float with values ranging from 1.0 to 5.0, based on aggregated user reviews.

Some simple examples:

final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
final LatLng location = place.getLatLng();

Get a place by ID

A place ID is a textual identifier that uniquely identifies a place. In the Google Places API for Android, you can retrieve the ID of a place by calling Place.getId(). The Place Autocomplete service also returns a place ID for each place that matches the supplied search query and filter. You can store the place ID and use it to retrieve the Place object again later.

To get a place by ID, call GeoDataClient.getPlaceById, passing one or more place IDs.

The API returns a PlaceBuffer in a PendingResult. The PlaceBuffer contains a list of Place objects that match the supplied place IDs.

The following code example shows calling getPlaceById() to get details for the specified place.

mGeoDataClient.getPlaceById(placeId).addOnCompleteListener(new OnCompleteListener<PlaceBufferResponse>() {
    @Override
    public void onComplete(@NonNull Task<PlaceBufferResponse> task) {
        if (task.isSuccessful()) {
            PlaceBufferResponse places = task.getResult();
            Place myPlace = places.get(0);
            Log.i(TAG, "Place found: " + myPlace.getName());
            places.release();
        } else {
            Log.e(TAG, "Place not found.");
        }
    }
});

Display attributions in your app

When your app displays information obtained from GeoDataClient.getPlaceById, the app must also display attributions. See the documentation on attributions.

More about place IDs

The place ID used in the Google Places API for Android is the same identifier as used in the Google Places API Web Service.

Each place ID can refer to only one place, but a single place can have more than one place ID. The most common case for handling multiple IDs for a place is when you've added a place that's initially scoped to your app, and then receives a Google-wide scope.

There are other circumstances which may cause a place to get a new place ID. For example, this may happen if a business moves to a new location.

When you request a place by specifying a place ID, you can be confident that you will always receive the same place in the response (if the place still exists). Note, however, that the response may contain a place ID that is different from the one in your request.

For more information, see the place ID overview.

Send feedback about...

location_on
Google Places API for Android