360 Secure SkillHub
360 安全技能中心

Navigation 3

汇集 Android Jetpack Navigation 3 的参考文档与代码配方,覆盖从 Navigation 2 迁移、类型安全路由、深链、多返回栈、对话与列表-详情等 Scenes、条件导航、结果返回,以及与 Hilt、Koin、ViewModel 的集成,帮助开发者按官方模式实现 Compose 导航。

ntriq-gh
ntriq-gh
热度 43.49
最近更新 2026-05-11 17:44:17
分类:开发依赖:纯提示词应用场景:代码生成 / 概念解释 / 模板 / API 集成 ...

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add navigation-3
Metadata
name
navigation-3
description
Learn how to install and migrate to Jetpack Navigation 3, and how to implement features and patterns such as deep links, multiple backstacks, scenes (dialogs, bottom sheets, list-detail, two-pane, supporting pane), conditional navigation (such as logged-in navigation vs anonymous), returning results from flows, integration with Hilt, ViewModel, Kotlin, and view interoperability.
license
Complete terms in LICENSE.txt
metadata
{"author":"Google LLC","keywords":["recipe","Android","Navigation 2","Navigation 3","migration","Compose","guide","dependencies","NavKey","NavHost","NavDisplay","BottomSheet","list-detail","scenes","two-pane","supporting pane","multiple backstacks","dialog","Hilt","ViewModel","View interop."]}

Migration guide

  • Navigation 2 to Navigation 3 migration guide: Step-by-step guide to migrate an Android application from Navigation 2 to Navigation 3, covering dependency updates, route changes, state management, and UI component replacements.

Requirements

Developer documentation

  • *Navigation 3. Search documentation for more information on basics, saving and managing navigation state, modularizing navigation code, creating custom layouts using Scenes, animating between destinations, or applying logic or wrappers to destinations.

Recipes

Code examples showcasing common patterns.

Basic API usage

Common UI

  • Common UI: Demonstrates how to implement a common navigation UI pattern with a bottom navigation bar and multiple back stacks, where each tab in the navigation bar has its own navigation history.

Deep links

  • Basic: Shows how to parse a deep link URL from an Android Intent into a navigation key.
  • Advanced: Shows how to handle deep links with a synthetic back stack and correct "Up" navigation behavior.

Scenes

Use built-in Scenes

  • Dialog: Shows how to create a Dialog.

Create custom Scenes

  • BottomSheet: Shows how to create a BottomSheet destination.
  • List-Detail Scene: Demonstrates how to implement adaptive list-detail layouts using the Navigation 3 Scenes API.
  • Two pane Scene: Demonstrates how to implement adaptive two-pane layouts using the Navigation 3 Scenes API.

Material Adaptive

  • Material List-Detail: Demonstrates how to implement an adaptive list-detail layout using Material 3 Adaptive.
  • Material Supporting Pane: Demonstrates how to implement an adaptive supporting pane layout using Material 3 Adaptive.

Animations

  • Animations: Shows how to override the default animations for all destinations and a single destination.

Common back stack behavior

  • Multiple back stacks: Shows how to create multiple top level routes, each with its own back stack. Top level routes are displayed in a navigation bar allowing users to switch between them. State is retained for each top level route, and the navigation state persists config changes and process death.

Conditional navigation

  • Conditional navigation: Switch to a different navigation flow when a condition is met. For example, for authentication or first-time user onboarding.

Architecture

Working with ViewModel

Passing navigation arguments

  • Basic ViewModel : Navigation arguments are passed to a ViewModel constructed using viewModel()

Returning results