我希望从Autocomplete Places服务中获取预测结果的位置细节(城市名称、邮政编码等)。我的代码如下:
Places.GeoDataApi.getAutocompletePredictions(googleApiClient, query, bounds, null)
.setResultCallback(
new ResultCallback<AutocompletePredictionBuffer>() {
@Override
public void onResult(AutocompletePredictionBuffer buffer) {
if (buffer == null)
return;
if (buffer.getStatus().isSuccess()) {
for (AutocompletePrediction prediction : buffer) {
// How to get cityName here
}
}
buffer.release();
}
}, 15, TimeUnit.SECONDS);
这个可行吗?我该如何实现它? 如果我通过placeId查找地点详情,我也得不到我想要的:
Places.GeoDataApi.getPlaceById(googleApiClient, placeId)
.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (places.getStatus().isSuccess()) {
// How to get cityName here
}
places.release();
}
});