Navigation Event
Intercept back gestures and run Predictive Back animations using the NavigationEvent...
Install
npx skills add android/skills --skill navigation-event -g -a claude-code -y- Repository
- android/skills10.2k
- Category
- Design
- Updated
- 6d ago
- License
- Complete terms in LICENSE.txt
- Context cost
- Mediumabout 3,000 tokens
- Runs scripts
- No, instructions only
What it does
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+.
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:


