Dialog Destinations - Android Developers
Dialog Destinations - Android Developers
In Android navigation, the term dialog destination refers to destinations within the app's
navigation graph which take the form of dialog windows, overlaying app UI elements and
content.
(/reference/kotlin/androidx/navigation/
NavGraphBuilder#(androidx.navigation.NavGraphBuilder).dialog(kotlin.collections.Map,kotlin.Function
1))
function. The function behaves essentially the same as
(/reference/kotlin/androidx/navigation/
NavGraphBuilder#(androidx.navigation.NavGraphBuilder).composable(kotlin.collections.Map,kotlin.col
lections.List,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Fun
ction2))()
, only it creates a dialog destination rather than a hosted destination
(/guide/navigation/design).
@Serializable
object Home
@Serializable
object Settings
@Composable
1 of 4 11/9/24, 12:30
Dialog destinations | Android Developers https://developer.android.com/guide/navigation/design/dia...
@Composable
fun MyApp() {
val navController = rememberNavController()
NavHost(navController, startDestination = Home) {
composable<Home> { HomeScreen(onNavigateToSettings = { navController.navigate
dialog<Settings> { SettingsScreen() }
}
}
Dialog destinations appear over the previous destination in the . Use them when
the dialog represents a separate screen in your app that needs its own lifecycle and
saved state, independent of any other destination in your navigation graph. You might
prefer to use an (/jetpack/compose/components/dialog) or related composable if
you want a dialog for a less complex prompt, such as a con�rmation.
2 of 4 11/9/24, 12:30
Dialog destinations | Android Developers https://developer.android.com/guide/navigation/design/dia...
Note: Because bo�om sheets in Compose are not built on , they need their own destination
type. See the Accompanist Navigation Material documentation
(h�ps://google.github.io/accompanist/navigation-material/) for an example implementation.
If you are working with fragments and you are using the Kotlin DSL
(/guide/navigation/design/kotlin-dsl) to create your graph, adding a dialog destination is very
similar to when using Compose.
3 of 4 11/9/24, 12:30
Dialog destinations | Android Developers https://developer.android.com/guide/navigation/design/dia...
...
...
<∕navigation>
Content and code samples on this page are subject to the licenses described in the Content License
(/license). Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its a�liates.
4 of 4 11/9/24, 12:30