Current Place

Deprecation notice: Google Play Services version of the Places SDK for Android

Notice: The Google Play Services version of the Places SDK for Android
(in Google Play Services 16.0.0) is deprecated as of January 29, 2019,
and will be turned off on July 29, 2019. A new version of the
Places SDK for Android is now available. We recommend updating to
the new version as soon as possible. For details, see the
migration guide.

Using the Places SDK for Android, you can discover the place at the
device's currently-reported location. Examples of places include local
businesses, points of interest, and geographic locations.

Permissions

If your app uses
PlacesClient.findCurrentPlace(),
users of your app must consent to ACCESS_FINE_LOCATION. The
library automatically requests the appropriate permissions for you (you do
not need to explictly request them, as they are already declared in the
library's manifest):

IMPORTANT!findCurrentPlace()
does not support the following fields: Place.Field.OPENING_HOURS,
Place.Field.PHONE_NUMBER, and Place.Field.WEBSITE_URI.
Read more about place data fields.

The API returns a
FindCurrentPlaceResponse
in a
Task.
The FindCurrentPlaceResponse contains a list of
PlaceLikelihood
objects representing places where the device is likely to be located. For
each place, the result includes an indication of the likelihood that the
place is the right one. The list may be empty, if there is no known place
corresponding to the given device location.

The likelihood provides a relative probability
of the place being the best match within the list of returned places for a
single request. You can't compare likelihoods across different requests.

The value of the likelihood will be between 0.0 and 1.0.

For example, to represent a 55% likelihood that the correct place is Place
A, and a 35% likelihood that it's Place B, the response has two members,
Place A with a likelihood of 0.55 and Place B with a likelihood of 0.35.

You can use a CancellationToken
to attempt to cancel a request to any of the request classes (for example,
FetchPlaceRequest). Cancellation is done on a best-effort basis.
Once a cancellation request is issued, no response will be returned.
Issuing a cancellation token does NOT guarantee that a particular request
will be cancelled, and you may still be charged for the request even if no
response is returned.