Migrating to the GoogleApi Client

The 11.2.0 release of the Google Play services SDK includes a new way to access
the Places API for Android. The GoogleApi client is easier
to use than its predecessor (GoogleApiClient), since it automatically manages
connections to Google Play services. This reduces the amount of boilerplate
code in your app, and can help to eliminate many common pitfalls. The new API
offers a number of improvements:

The connection process is managed automatically, so the new API is less work
to implement.

API calls now automatically wait for the service connection to be
established, removing the need to wait for onConnected before making
requests.

The code is self-contained, and can easily be moved into a shared utility
class or similar.

Updating your app to use the GoogleApi client requires some changes to your
Places API for Android implementation. This guide describes
the changes to the Places API for Android, and recommends
steps to take when updating your app to use the new client.

Overview

The main areas of change are as follows:

There are two new entry points: GeoDataClient and PlaceDetectionClient.
Instead of creating one GoogleApiClient instance to cover all APIs, your app
must now instantiate both GeoDataClient and PlaceDetectionClient.

Since connection callbacks are no longer required, you can safely refactor
your app to remove them.

The new Places API methods are now asynchronous,
and return a Task rather than a PendingResult.

Load the Places API

To load the Places API, declare the entry
points, then instantiate the clients in your fragment's or activity's
onCreate()
method as shown in the following example:

Comparison

The new Places API methods are now asynchronous,
and return a Task rather than a PendingResult. The data structures have not
changed, so your existing code for handling results shouldn't need updating.
The following code examples compare the new and old versions of GetCurrentPlace():