我收到错误
无法解析符号“ PlaceBuilder”
在我的PlaceAutocompleteAdapter中使用它时。如果是这样,则是由于com.google.android.gms.location.places.PlaceBuffer
已被弃用。
如果这是原因,我该如何更新代码?
private AdapterView.OnItemClickListener mAutoCompleteClickListener = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
hideSoftKeyboard();
final String placeId = mPlaceAutocompleteAdapter.getItem(i).getPlaceId();
PendingResult<PlaceBuilder> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId);
placeResult.setResultCallback(mUpdatePlaceDetailsCllback);
}
};
private ResultCallback<PlaceBuffer> mUpdatePlaceDetailsCllback = new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
if(!places.getStatus().isSuccess()){
Log.d(TAG, "onResult: Place query did not complete successfully: " + places.getStatus().toString());
places.release();
return;
}
final Place place = places.get(0);
try{
mPlace = new PlaceInfo();
mPlace.setName(place.getName().toString());
}catch (NullPointerException e){
Log.e(TAG, "onResult: NullPointerException: " + e.getMessage());
}
if (mPlace!=null){
moveCamera(mPlace.getLatlng(), DEFAULT_ZOOM, mPlace.getName());
}
places.release();
}
};
答案 0 :(得分:0)
PlaceBuffer确实已被弃用。请按照Google指南https://developers.google.com/places/android-sdk/client-migration
迁移到新的Android版Places SDK。希望这会有所帮助!