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:
![a back stack with a dialog destination on top](https://developer.android.com/static/images/guide/navigation/backstack-1.png?authuser=0000)
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:
![a back stack with two dialog destinations on top](https://developer.android.com/static/images/guide/navigation/backstack-2.png?authuser=0000)
Dialog
destinations on top.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:
![the dialog destinations are popped, and the new destination
is added](https://developer.android.com/static/images/guide/navigation/backstack-3.png?authuser=0000)
Dialog
destinations
are popped, and the new destination is added.