由於firebase因爲必須爲firebase添加最新的9.0.0或更高版本,所以我將Play-services升級到9.4.0後,我正面臨問題,因爲AutocompletePrediction prediction.getDescription()現在顯示爲在我的項目中找不到,除了Gradle更新之外,我還想改變任何內容,我認爲新的播放服務缺少.getDescription方法,請幫我解決 這是我的新搖籃'編 'com.google.firebase:火力核心:9.4.0'Google Places api AutocompletePrediction prediction.getDescription()MissingAfter升級到Play服務到9.4.0
compile 'org.osmdroid:osmdroid-android:[email protected]'
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'
} 應用插件: 'com.google.gms.google服務' 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;
}`
你是最好的我看到這些方法,而我在調試讓我嘗試他們,我希望他們會工作 – haider
@haider:你介意在移植到9.4.0後分享你的代碼 - 我有很多與此有關的麻煩。 – menawi
@menawi使用我的上面的代碼有問題,只需用prediction.getFullText() – haider