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

Displaying Attributions

When displaying data from the Google Places API for Android, such as autocomplete results or place name and address, there are some attribution and Google logo requirements you must comply with.

  1. Overview
  2. Displaying a map
  3. The 'Powered by Google' attribution
  4. Attributions for third-party content

Overview

The attribution and logo requirements fall into the following categories:

  • A Google map, if a map is displayed.
  • The 'Powered by Google' attribution.
  • Attributions for content supplied by third parties.

The requirements apply to the place picker UI widget as well as the programmatic API calls. If the app has retrieved a place via the place picker and then shows the data on a follow-up screen without a map, the app must show attributions on the follow-up screen.

Displaying a map

You do not need to display a map. If your application displays Places API data on a map, that map must be a Google map with the Google logo visible. Applications that display Places API data on the same screen as a Google map are not required to provide further attribution to Google.

Note that you're still required to display any relevant attributions for third-party content.

The 'Powered by Google' attribution

If your application displays Places API data on a page or view without a Google Map, you must show a 'Powered by Google' image with that data. For example, if your application displays a list of places retrieved by the API on one screen, and a Google Map with those places on another screen, the first screen must show the 'Powered by Google' attribution.

The 'Powered by Google' image is included in the Google Play services library, in the correct sizes for Android apps. You may not resize or modify these images in any way:

  • For use on a light background: @drawable/powered_by_google_light
  • For use on a dark background: @drawable/powered_by_google_dark

Attributions for third-party content

Follow these instructions to retrieve third-party attributions from the place picker or other API calls, and to display the attributions in your app.

Retrieving attributions from the place picker

To retrieve attributions from the place picker, call PlacePicker.getAttributions() passing it the current Intent containing the place the user has selected. The method returns an HTML string, or null if there are no attributions to display.

String thirdPartyAttributions = PlacePicker.getAttributions(intent);
if (thirdPartyAttributions == null) {
  thirdPartyAttributions = "";
}

Retrieving attributions from a PlaceLikelihoodBuffer

If your app displays information obtained by requesting the device's current place, the app must also display third-party attributions for the place details obtained.

The API returns a PlaceLikelihoodBuffer containing a list of likely places. To retrieve attributions from the PlaceLikelihoodBuffer, call PlaceLikelihoodBuffer.getAttributions(). The method returns an HTML character sequence, or null if there are no attributions to display.

PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
    .getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
  @Override
  public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
    final CharSequence thirdPartyAttributions =
        likelyPlaces.getAttributions();
    ...
  }
  likelyPlaces.release();
});

Retrieving attributions from a PlaceBuffer

If your app displays information obtained by calling get place by ID, the app must also display third-party attributions for the place details obtained.

The API returns a PlaceBuffer containing a list of places. To retrieve attributions from the PlaceBuffer, call PlaceBuffer.getAttributions(). The method returns an HTML character sequence, or null if there are no attributions to display.

Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId)
    .setResultCallback(new ResultCallback<PlaceBuffer>() {
  @Override
  public void onResult(PlaceBuffer places) {
    if (places.getStatus().isSuccess()) {
        ...
        final CharSequence thirdPartyAttributions =
            places.getAttributions();
    }
    places.release();
  }
});

Displaying attributions for a photo

If your app displays photos, you must show attributions for each photo that has them. To get attributions for a photo, call PlacePhotoMetadata.getAttributions(). The method returns an HTML character sequence, or null if there are no attributions to display.

Places.GeoDataApi.getPlacePhotos(mGoogleApiClient, placeId)
    .setResultCallback(new ResultCallback<PlacePhotoMetadataResult>() {
  @Override
  public void onResult(PlacePhotoMetadataResult photos) {
    if (photos.getStatus().isSuccess()) {
      // Get attribution for the first photo in the list.
      PlacePhotoMetadataBuffer photoResults = photos.getPhotoMetadata();
      if (photoResults.getCount() > 0) {
        PlacePhotoMetadata photo = photoMetadata.get(0);
        CharSequence attribution = photo.getAttributions();
      }
      photoResults.release();
    }
});

Displaying third-party attributions

Attributions to third-party providers contain content in HTML format that you must display to the user in the format in which they are provided. Any links included in the HTML must be preserved. We recommend that your app shows this information below the place details.

The API generates attributions for all the places that are used by the app. The attributions are supplied per API call, not per place.

One way to display the attributions is with a TextView. For example:

TextView attributionsText = (TextView) findViewById(R.id.attributions);
String thirdPartyAttributions = PlacePicker.getAttributions(intent);
if (thirdPartyAttributions == null) {
  thirdPartyAttributions = "";
}
attributionsText.setText(Html.fromHtml(thirdPartyAttributions));

Example of a third-party attribution

Listings by <a href="https://www.example.com/">Example Company</a>

Send feedback about...

location_on
Google Places API for Android