不推荐使用FragmentManager.有替代方法或我现在可以做什么?
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setonPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// Todo: Get info about the selected place.
destination = place.getName().toString();
destinationLatLng = place.getLatLng();
}
@Override
public void onError(Status status) {
// Todo: Handle the error.
}
});
解决方法
此方法在API级别28中已弃用.
使用FragmentActivity.getSupportFragmentManager()