Use myDialogFragment.setTargetFragment(this, MY_REQUEST_CODE)
from the place where you show the dialog, and then when your dialog is finished, from it you can call getTargetFragment().onActivityResult(getTargetRequestCode(), ...)
, and implement onActivityResult()
in the containing fragment.
It seems like an abuse of onActivityResult()
, especially as it doesn’t involve activities at all. But I’ve seen it recommended by official google people, and maybe even in the api demos. I think it’s what g/setTargetFragment()
were added for.