Google Places api AutocompletePrediction prediction.getDescr



由于firebase,我将播放服务升级到9.4.0后,由于必须为firebase添加最新版本9.0.0或更高版本,我面临着自动完成预测的问题。getDescription()现在显示为在我的项目中找不到,除了Gradle更新之外,我没有更改任何内容,我认为新的播放服务缺少.getDescription方法,请帮助我这是我的新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;
}`

getDescription在Google文档中已被弃用。

getDescription()现在已弃用请使用getFullText()、getPrimaryText()和/或getSecondaryText()来检索完整或部分描述,getMatchedSubstrings()现在已弃用。请使用getFullText()来更容易地格式化匹配。https://developers.google.com/android/guides/releases

相关内容

  • 没有找到相关文章

最新更新