0

I am making an android app in which i have an AutocompleteTextview where i will enter places names and suggestion will come out now i am using google-maps api for this my code is given below now my code is not running can someone pls tell me wht have i done wrong.

PendingResult results = Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient , null, BOUNDS_GREATER_SYDNEY, null);
            Log.d("hii", "3");
            AutocompletePredictionBuffer autocompletePredictions = (AutocompletePredictionBuffer) results
                    .await(60, TimeUnit.SECONDS);
            Log.d("hii", "4");
            final Status status = autocompletePredictions.getStatus();
            if (!status.isSuccess()) {
                Log.d("hii", "5");
  //              Toast.makeText(Location_AutoComplete.this, "Error contacting API: " + status.toString(),
  //                      Toast.LENGTH_SHORT).show();
                Log.e("hii", "Error getting autocomplete prediction API call: " + status.toString());
                autocompletePredictions.release();
            }
            Log.d("hii", "6");
            Log.i("hii", "Query completed. Received " + autocompletePredictions.getCount()
                    + " predictions.");

            // Copy the results into our own data structure, because we can't hold onto the buffer.
            // AutocompletePrediction objects encapsulate the API response (place ID and description).
            int i = 0;
            Log.d("hii", "7");

            String[] locsss = new String[autocompletePredictions.getCount()];
            Iterator<AutocompletePrediction> iterator = autocompletePredictions.iterator();
            ArrayList resultList = new ArrayList<>(autocompletePredictions.getCount());
            while (iterator.hasNext()) {
                Log.d("hii", "8");
                AutocompletePrediction prediction = iterator.next();
                // Get the details of this prediction and copy it into a new PlaceAutocomplete object.
                Log.d("hii", "location "+prediction.getPlaceId());
                locsss[i] = prediction.getPlaceId();
  //              resultList.add(new PlaceAutocomplete(prediction.getPlaceId(),
  //                      prediction.getDescription()));
                i++;
            }
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(Location_AutoComplete.this, android.R.layout.simple_list_item_1, locsss);
            mAutocompleteView.setAdapter(adapter);
            mAutocompleteView.setOnItemClickListener(
                    new AdapterView.OnItemClickListener() {
                        @Override
                        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                            //
                        }
                    }
            );
divanshu pratap
  • 323
  • 1
  • 4
  • 11

0 Answers0