Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places api AutocompletePrediction prediction.getDescription() MissingAfter upgrading to Play services to 9.4.0

After i upgraded play-services to 9.4.0 due to firebase, because its must to add latest version 9.0.0 or above for firebase, i am facing problem as AutocompletePrediction prediction.getDescription() is now shown as not found in my project, i havnt changed anything except the Gradle update, i think the new play services is missing the .getDescription method, plz help me out This is my new Gradle ` compile 'com.google.firebase:firebase-core:9.4.0'

compile 'org.osmdroid:osmdroid-android:5.1@aar'
compile 'com.github.MKergall.osmbonuspack:OSMBonusPack:v5.7'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.android.gms:play-services-identity:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'

} apply plugin: 'com.google.gms.google-services' and this one is my java file where >getDescription is missing public PlaceAutocomplete getItem(int position) { return mResultList.get(position); }

private ArrayList<PlaceAutocomplete> getPredictions(CharSequence constraint) {
    if (mGoogleApiClient != null) {
        Log.i(TAG, "Executing autocomplete query for: " + constraint);
        PendingResult<AutocompletePredictionBuffer> results =
                Places.GeoDataApi
                        .getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
                                mBounds, mPlaceFilter);
        // Wait for predictions, set the timeout.
        AutocompletePredictionBuffer autocompletePredictions = results
                .await(60, TimeUnit.SECONDS);
        final Status status = autocompletePredictions.getStatus();
        if (!status.isSuccess()) {
            Toast.makeText(getContext(), "Error: " + status.toString(),
                    Toast.LENGTH_SHORT).show();
            Log.e(TAG, "Error getting place predictions: " + status
                    .toString());
            autocompletePredictions.release();
            return null;
        }

        Log.i(TAG, "Query completed. Received " + autocompletePredictions.getCount()
                + " predictions.");
        Iterator<AutocompletePrediction> iterator = autocompletePredictions.iterator();
        ArrayList resultList = new ArrayList<>(autocompletePredictions.getCount());
        while (iterator.hasNext()) {
            AutocompletePrediction prediction = iterator.next();
            resultList.add(new PlaceAutocomplete(prediction.getPlaceId(),
                    prediction.getDescription()));
        }
        // Buffer release
        autocompletePredictions.release();
        return resultList;
    }
    Log.e(TAG, "Google API client is not connected.");
    return null;
}`
like image 256
haider Avatar asked Mar 12 '23 13:03

haider


1 Answers

getDescription is deprecated as mentioned on Google docs.

getDescription() is now deprecated. Please use getFullText(), getPrimaryText(), and/or getSecondaryText() to retrieve the full or partial description, getMatchedSubstrings() is now deprecated. Please use getFullText() to format matches more easily. https://developers.google.com/android/guides/releases

like image 129
Vindhya Pratap Singh Avatar answered May 01 '23 08:05

Vindhya Pratap Singh