I'm having problems with Android Google Places API - auto complete feature.
I'm trying to use Places.GeoDataApi.getAutocompletePredictions() method to get the placeId, however, it doesn't work.(The output doesn't even show "can't get the value") Could anyone help me?
Here is my Java code:
PendingResult<AutocompletePredictionBuffer> result =
Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, query,
mLatLonBounds, null);
result.setResultCallback(new ResultCallback<AutocompletePredictionBuffer>() {
@Override
public void onResult(@NonNull AutocompletePredictionBuffer autocompletePredictions) {
if (autocompletePredictions.getStatus().isSuccess()) { //如果回傳SUCCESS
Iterator<AutocompletePrediction> iterator = autocompletePredictions.iterator();
resultList = new ArrayList<>(autocompletePredictions.getCount());
while (iterator.hasNext()) {
AutocompletePrediction prediction = iterator.next();
resultList.add(prediction.getPlaceId().toString());
}
}
else {
resultList.add("can't get the vaule");
}
autocompletePredictions.release();
}
});
textView.setText(resultList.get(0).toString());
Thanks.