0
Hello, I’m having problems with Getautocompletepredictions from google Api, I’m not able to know if I can fix the function or I have to update the api and redo it.
Here comes the code!
private ArrayList<AutocompletePrediction> getAutocomplete(CharSequence constraint) {
ArrayList<AutocompletePrediction> result = null;
if (mGoogleApiClient.isConnected()) {
Logger.d(TAG, this.getClass().getName(), "getAutocomplete", "Starting autocomplete query for: " + constraint);
PendingResult<AutocompletePredictionBuffer> results = Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, constraint.toString(), mBounds, mPlaceFilter);
AutocompletePredictionBuffer autocompletePredictions = results.await(60, TimeUnit.SECONDS);
final Status status = autocompletePredictions.getStatus();
if (status.isSuccess()) {
Logger.d(TAG, this.getClass().getName(), "getAutocomplete", "Query completed. Received " + autocompletePredictions.getCount() + " predictions.");
result = DataBufferUtils.freezeAndClose(autocompletePredictions);
}
else{
UiUtil.notifyCommunicationError((Activity) getContext(), new CommunicationException(CommunicationException.ErrorType.SERVER_RESPONSE_ERROR, getContext().getString(R.string.home_explore_error_address_not_found)));
Logger.e(TAG, this.getClass().getName(), "getAutocomplete", "Error getting autocomplete prediction API call: " + status.toString(), null);
autocompletePredictions.release();
}
}
else{
Logger.e(TAG, this.getClass().getName(), "getAutocomplete", "Google API client is not connected for autocomplete query.", null);
}
return result;
}
That one final Status status = autocompletePredictions.getStatus();
is returning me null.