Fragment declared target fragment that does not belong to this FragmentManager
问题 I have made an activity A which has a fragment X in it. In fragment X, EditText item has on click event which opens fragment Y. This fragment displays a list of names. I press a name in the list, fragment Y closes and sends the selected name of to fragment X EditText. Here's the code I wrote: YFragment y = new YFragment(); y.setTargetFragment(x.class, code); getActivity().getSupportFragmentManager() .beginTransaction() .replace(R.id.frame, y) .addToBackStack(null) .commit(); In fragment Y I