navigation-event
O que ela faz
Esta skill orienta a interceptação do gesto de voltar e a execução de animações de volta preditiva em um app Android em Jetpack Compose. Também cobre contêineres aninhados, como abas, e a migração do antigo BackHandler. É para desenvolvedores Android que precisam de um comportamento personalizado de voltar.
Quando usar
- ✓Quando você precisa interceptar o gesto de voltar em uma tela Compose.
- ✓Quando você quer animações de volta preditiva no seu app Android.
- ✓Quando você precisa migrar código antigo de BackHandler para a biblioteca NavigationEvent.
Link da skill
https://github.com/android/skills/blob/main/navigation/navigation-event/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Faça o gesto de voltar fechar primeiro a minha folha inferior no app Compose, com a animação de volta preditiva.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
A skill configura o despachante da activity e o manipulador de voltar do Compose e depois limita cada um à tela, aba ou diálogo certo. Também cobre a migração de código legado de BackHandler em versões mais novas do Android.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do GitHub.
Common guidelines
- For architecture concepts : To understand the foundational architecture, continuous gesture event lifecycles, or class definitions of the Navigation Event library, read Navigation Event overview.
- For Android target : If compile SDK is lower than 36, set it to
36or higher inbuild.gradle.kts. - For Compose Android target: The project must use Jetpack Compose for Compose-specific APIs. This skill is scoped exclusively to Compose Android (Android Views and non-Compose implementations are excluded).
- For activity dispatchers :
ComponentActivityautomatically implementsNavigationEventDispatcherOwnerout-of-the-box. You must use the built-innavigationEventDispatcherwithout creating anonymous delegate owners or overriding member properties. - For dialog scoping : Floating windows (Compose
Dialog,ModalBottomSheet,ComponentDialog) automatically provide aNavigationEventDispatcherOwner. You don't need manualCompositionLocalProviderpropagation for dialogs. - For parent-child dispatcher hierarchies : When scoping navigation handling to
ViewPagers, tabbed interfaces, or nested navigation containers in Compose, userememberNavigationEventDispatcherOwner()to create a child owner linked to the parent. Disabling the owner (enabled = false) automatically cascades to disable all child handlers. - For Compose handlers : A one-to-one relationship between
NavigationEventStateand handlers is strictly enforced. Never bind the sameNavigationEventStateto multiple activeNavigationBackHandlerinstances (IllegalArgumentException).
Step 1: Plan
To complete this step, you MUST ensure the following:
- Identify the target platform : Verify the app is targeting Compose Android. If
compileSdkis lower than 36, set it to36or higher inbuild.gradle.kts. - Navigation check: Check if Navigation 3 is in use. If it is in use, use Navigation 3's built-in back navigation support rather than manually implementing low-level dispatchers from this skill.
- Hierarchy check : Identify host Activities,
ViewPagers, tabbed interfaces, or nested navigation hosts that require back gesture interception or parent-child dispatcher linking. - Migration check : Check if the project is migrating from back handling (
OnBackPressedCallback,BackHandler,onBackPresser) toNavigationEventandNavigationBackHandler. - Input interception : Detect where the app is intercepting navigation events from gestures or hardware button presses requiring translation to
NavigationEvent.
Step 2: Set up dependencies
To complete this step, you MUST ensure the following:
- For setting up compile SDKs, declaring catalog versions, and adding dependencies, follow setup guide.
Step 3: Configure dispatcher and inputs
To complete this step, you MUST ensure the following:
- To configure your dispatcher, leverage automatic
ComponentActivityorComponentDialogowner resolution. - Link parent-child dispatchers in Compose following dispatcher guide.
Step 4: Handle back navigation and UI transitions
To complete this step, you MUST ensure the following:
- To create navigation event handlers, integrate back gesture interception in Compose, animate UI components during swipes, and migrate from legacy back handlers, follow handle back guide.
Step 5: Clean up resources
[!WARNING] Warning: Compose APIs perform teardown automatically. When using Compose APIs such as
NavigationBackHandlerandrememberNavigationEventDispatcherOwner(), handler removal and dispatcher disposal occur automatically when the composable leaves the composition.
You MUST perform explicit manual cleanup only when managing custom dispatchers or non-Compose handlers:
- Call
remove()on active handlers during teardown. - Call
isEnabled = falseto temporarily disable navigation subtrees. - Call
dispose()on dispatcher instances when hosting components are destroyed. Disposing a parent dispatcher automatically cascades to all child dispatchers.
Core troubleshooting guidelines
1. Activity dispatcher setup (StackOverflowError recursion)
ComponentActivity im
Perguntas frequentes
Funciona para apps com Android Views?
Não. A skill se limita a apps Android em Compose, e Views ficam fora do escopo.
Qual alvo do Android é necessário?
Se o compile SDK do app estiver abaixo de 36, a skill o eleva para 36 ou mais.
Diálogos precisam de configuração extra?
Não. Diálogos e folhas inferiores fornecem o próprio despachante, então não é preciso fiação extra.
Detalhes
Descrição original do autor
Intercept back gestures and run Predictive Back animations using the NavigationEvent (androidx.navigationevent) library in Compose Android. Handles Activity setup, parent-child dispatcher scoping in `ViewPagers` or tabs, Compose `NavigationBackHandler`, and migration from legacy `BackHandler` on SDK 36+.
repo: android/skills
Popularidade
- Estrelas no GitHub
- 10 mil
- Posição no ranking
- #11925
- Licença
- Apache-2.0
- Atualizada em
- 29/10/2026
Comentários
- …
Mais skills deste repositório
agp-9-upgrade
10 milAjuda seu agente a atualizar um app Android para o Android Gradle Plugin 9 e resolver suas mudanças incompatíveis. Não serve para projetos multiplataforma.
camerax
10 milAjuda seu agente a criar recursos de câmera no Android com o CameraX, incluindo gravação de vídeo, controles de hardware, ML Kit e efeitos do Media3.
android-for-cars-parked-apps
10 milAjuda seu agente a adaptar um app Android de vídeo, jogo ou navegador para rodar como app estacionado no Android Auto e no Android Automotive.
appfunctions
10 milAjuda seu agente a encontrar fluxos de trabalho principais de um app Android e expô-los como AppFunctions que agentes de IA e comandos de voz podem executar.
Skills parecidas
android-clean-architecture
280 milFaz seu agente organizar projetos Android de forma eficiente. Ele estrutura o código para facilitar a manutenção e o desenvolvimento de novos recursos.
compose-multiplatform-patterns
280 milAjuda seu agente a usar Compose Multiplatform e Jetpack Compose em projetos KMP. Cobre estado, navegação, temas e performance.
dart-flutter-patterns
280 milFaz seu agente escrever código para apps Dart e Flutter. Ele usa padrões modernos para criar apps robustos e fáceis de gerenciar.