navigation-event
What it does
This skill guides catching back gestures and running predictive back animations in a Jetpack Compose Android app. It also covers nested containers like tabs and the move from the older BackHandler. It is for Android developers who need custom back behavior.
When to use it
- ✓When you need to intercept the back gesture in a Compose screen.
- ✓When you want predictive back animations in your Android app.
- ✓When you need to move older BackHandler code to the NavigationEvent library.
Skill link
https://github.com/android/skills/blob/main/navigation/navigation-event/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Make the back gesture close my bottom sheet first in my Compose app, with the predictive back animation.”
5 new skills a week. 1 minute to read.
How it works
The skill sets up the activity's dispatcher and the Compose back handler, then scopes each one to the right screen, tab or dialog. It also covers migrating legacy BackHandler code on newer Android versions.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
Does it work for Android Views apps?
No. The skill is limited to Compose Android apps, and Views are excluded.
What Android target is needed?
If the app's compile SDK is below 36, the skill raises it to 36 or higher.
Do dialogs need extra setup?
No. Dialogs and bottom sheets provide their own dispatcher, so no extra wiring is needed.
Details
Original description by the author
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
Popularity
- GitHub stars
- 10k
- Ranking position
- #11925
- License
- Apache-2.0
- Updated
- 10/29/2026
Comments
- …
More skills from this repository
agp-9-upgrade
10kHelps your agent upgrade an Android app to Android Gradle Plugin 9 and work through its breaking changes. Not for multiplatform projects.
camerax
10kHelps your agent build Android camera features with CameraX, including video recording, hardware controls, ML Kit and Media3 effects.
android-for-cars-parked-apps
10kHelps your agent adapt an Android video, game or browser app to run as a parked app on Android Auto and Android Automotive.
appfunctions
10kHelps your agent find key workflows in an Android app and expose them as AppFunctions that AI agents and voice commands can run.
Similar skills
android-clean-architecture
280kMakes your agent organize Android projects efficiently. It structures the code to make maintenance and new feature development easier.
compose-multiplatform-patterns
280kHelps your agent use Compose Multiplatform and Jetpack Compose patterns in KMP projects, covering state, navigation, theming, and performance.
dart-flutter-patterns
280kMakes your agent write code for Dart and Flutter apps. It uses modern patterns to create robust and manageable apps.