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

Buffers

The Google Places API for Android includes a number of buffers, which require special handling to prevent your app suffering from memory leaks:

Note the following points when working with buffers:

  • To prevent a memory leak, you must release the buffer object when your app no longer needs it, by calling the buffer's release() method.
  • If you want to continue using the object contained in the buffer after you've released the buffer, call freeze() on the object before calling buffer.release(). Note that calling freeze() on an object may result in increased memory usage, because it may create an additional copy of the object. (It doesn't create an additional copy on an already-frozen object.) You should therefore freeze an object only if you need to access it after releasing the buffer.

The following example illustrates buffer handling for a PlaceBuffer

PlaceBuffer buffer = GeoDataApi.getPlaceById(id1, id2, ...);

Place place = buffer.get(0);

// It's OK to use the place object here, as the buffer hasn't been released yet.
String name = place.getName();

Place frozen = place.freeze();

buffer.release();

// If you call place.getName() here, an exception is thrown,
// because the buffer has been released.
// Instead, use the frozen Place object.
name = frozen.getName();

You can use isDataValid() at any time to determine if the object is available or not. For example, place.isDataValid() returns true before the call to buffer.release() and false afterwards. Note that frozen.isDataValid() returns true both before and after the buffer has been released.

Send feedback about...

location_on
Google Places API for Android