android - after orrientation change target fragment changes in dialog fragment

setTargetFragment should not be used to establish a relationship between parent/child fragments. It should only be used to link sibling fragments (i.e. those that exist within the same FragmentManager).

The reason it doesn't work between parent/child fragments is a fragment's target is saved and restored as an index into its own FragmentManager. So everything will be hunky dory until the framework restores an Activity after, for example, an orientation change. At that point the FragmentManager will look for the target fragment within itself instead of the parent FragmentManager.


I don't still understand why exactly getTargetFragment() didn't work for me, but replacing it with getParentFragment() solved my issue.