Search code examples
androiddialogdialogfragment

Re-display parent dialog after child dialog closes


In my app, I display a custom Dialog (using DialogFragment), which on certain action causes another custom Dialog to be shown (using another DialogFragment). This all works fine. However when the "child" dialog is closed, I want to return to the parent dialog (which is closed/hidden when the child is displayed).

I do not want just display another instance of the same dialog, as I need to maintain states and behaviours of the parent prior to the child being open. Therefore I need to re-display physically the same dialog.

I can't seem to find a way of doing so.


Solution

  • Coming back to it as I now got a solution that seems to work. Apparently, using dialog directly will close the previous dialog when a new one is opened. Yet, when using DialogFragment, the previous fragment stays on screen when the new fragment is displayed. Then when the dialog on the new fragment is closed the previous fragment is still visible - exactly what I need.