This document outlines how the use of dialog destinations can introduce unique considerations for how you need to manage your back stack.
Overview
One or more dialog destinations can only exist on the top of the back stack.
This is because when the user navigates to a destination that is not a dialog
destination, the NavController
automatically pops all dialog destinations off
the top of the stack. This ensures that the current destination is always fully
visible over other destinations on the back stack.
Destinations can be either hosted destinations, activity destinations, or dialog destination.
Example
If the back stack consists solely of hosted destinations that fill the navigation host, and the user navigates to a dialog destination, then the back stack might look similar to figure 2:
If the user then navigates to another dialog destination, it is then added to the top of the back stack, as shown in figure 3:
If the user then navigates to a non-floating destination, any dialog destinations are first popped from the top of the back stack before navigating to the new destination, as shown in figure 4: