En 'com.google.android.gms:play-services-location:9.4.0'
Impossible d'importer com.google.android.gms.location.places.Places
A cause de cela, impossible de construire GoogleApiClient
et également incapable d'utiliser Places.GeoDataApi.getPlaceById.
Mais en 'com.google.android.gms:play-services-location:8.4.0'
nous pouvons l'utiliser correctement.
mGoogleApiClient = new GoogleApiClient
.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId).setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (places.getStatus().isSuccess() && places.getCount() > 0) {
final com.google.android.gms.location.places.Place myPlace = places.get(0);
Log.i(TAG, "Place found: " + myPlace.getName());
map.addMarker(new MarkerOptions()
.position(myPlace.getLatLng())
.title(myPlace.getName().toString())
.snippet(myPlace.getAddress().toString()));
map.moveCamera(CameraUpdateFactory.newLatLng(myPlace.getLatLng()));
}
places.release();
}
});