/android-skills:navigation-eventfrom Android Skills
Intercepts back gestures and runs Predictive Back animations using the NavigationEvent library in Compose Android. Covers Activity setup, parent-child dispatcher scoping in ViewPagers/tabs, NavigationBackHandler, and migration from legacy BackHandler on SDK 36+.
Ships in Android Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
36 or higher in build.gradle.kts.ComponentActivity automatically implements NavigationEventDispatcherOwner out-of-the-box. You must use the built-in navigationEventDispatcher without creating anonymous delegate owners or overriding member properties.Dialog, ModalBottomSheet, ComponentDialog) automatically provide a NavigationEventDispatcherOwner. You don't need manual CompositionLocalProvider propagation for dialogs.ViewPagers, tabbed interfaces, or nested navigation containers in Compose, use rememberNavigationEventDispatcherOwner() to create a child owner linked to the parent. Disabling the owner (enabled = false) automatically cascades to disable all child handlers.NavigationEventState and handlers is strictly enforced. Never bind the same NavigationEventState to multiple active NavigationBackHandler instances (IllegalArgumentException).To complete this step, you MUST ensure the following:
compileSdk is lower than 36, set it to 36 or higher in build.gradle.kts.ViewPagers, tabbed interfaces, or nested navigation hosts that require back gesture interception or parent-child dispatcher linking.OnBackPressedCallback, BackHandler, onBackPresser) to NavigationEvent and NavigationBackHandler.NavigationEvent.To complete this step, you MUST ensure the following:
To complete this step, you MUST ensure the following:
ComponentActivity or ComponentDialog owner resolution.To complete this step, you MUST ensure the following:
[!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:
remove() on active handlers during teardown.isEnabled = false to temporarily disable navigation subtrees.dispose() on dispatcher instances when hosting components are destroyed. Disposing a parent dispatcher automatically cascades to all child dispatchers.ComponentActivity implements NavigationEventDispatcherOwner automatically
out-of-the-box. Don't override navigationEventDispatcher or wrap it in an
anonymous delegate owner.
Why this is RIGHT : Compose apps use ComponentActivity as the host.
LocalNavigationEventDispatcherOwner.current automatically resolves the
Activity's built-in dispatcher.
// RIGHT
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationContent()
}
}
}
Why this is WRONG : Implementing NavigationEventDispatcherOwner directly on
MainActivity and overriding navigationEventDispatcher with a new instance
shadows the library's extension property, causing a recursive infinite loop
crash on launch (StackOverflowError). Creating redundant anonymous delegate
owners (object : NavigationEventDispatcherOwner) is unnecessary.
// WRONG
class MainActivity : ComponentActivity(), NavigationEventDispatcherOwner {
override val navigationEventDispatcher = NavigationEventDispatcher() // Shadow loop crash
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationContent()
}
}
}
Floating windows (Compose Dialog, ModalBottomSheet, and any window backed by
ComponentDialog) automatically provide a NavigationEventDispatcherOwner.
Don't manually re-provide LocalNavigationEventDispatcherOwner using
CompositionLocalProvider inside dialogs.
Why this is RIGHT : ComponentDialog handles navigation dispatchers
automatically. Compose Dialog components resolve their dispatcher owner
out-of-the-box without manual propagation.
// RIGHT
@Composable
fun MyDialog(onDismiss: () -> Unit) {
Dialog(onDismissRequest = onDismiss) {
val navigationState = rememberNavigationEventState(currentInfo = NavigationEventInfo.None)
NavigationBackHandler(
state = navigationState,
onBackCompleted = onDismiss
)
}
}
Why this is WRONG : Wrapping dialog content in a manual
CompositionLocalProvider creates redundant boilerplate and obscures the
automatic dispatcher resolution provided by ComponentDialog.
// WRONG
@Composable
fun MyDialog(onDismiss: () -> Unit) {
val dispatcherOwner = LocalNavigationEventDispatcherOwner.current!!
Dialog(onDismissRequest = onDismiss) {
// Redundant: ComponentDialog provides NavigationEventDispatcherOwner automatically
CompositionLocalProvider( LocalNavigationEventDispatcherOwner provides dispatcherOwner) {
val navigationState = rememberNavigationEventState(currentInfo = NavigationEventInfo.None)
NavigationBackHandler(
state = navigationState,
onBackCompleted = onDismiss
)
}
}
}
ViewPagers and nested navigation)When managing nested UI hierarchies such as ViewPagers, tabbed
interfaces, or custom navigation containers in Compose, use
rememberNavigationEventDispatcherOwner() to create a child owner linked to the
composition hierarchy. Setting enabled = false on the child owner
automatically disables its dispatcher and all registered child handlers.
Why this is RIGHT : Using rememberNavigationEventDispatcherOwner(enabled = isSelected) creates a scoped child dispatcher linked to the parent from
LocalNavigationEventDispatcherOwner.current. Providing it using
CompositionLocalProvider ensures non-visible tabs or pages automatically stop
intercepting back gestures without leaking handlers.
// RIGHT: Scoping child navigation in a ViewPager or Tab interface
@Composable
fun TabPage(isSelected: Boolean) {
val childOwner = rememberNavigationEventDispatcherOwner(enabled = isSelected)
CompositionLocalProvider(LocalNavigationEventDispatcherOwner provides childOwner) {
val navigationState = rememberNavigationEventState(currentInfo = NavigationEventInfo.None)
NavigationBackHandler(
state = navigationState,
onBackCompleted = { /* Handle page back navigation */ }
)
// Page content
}
}
Why this is WRONG : Creating unlinked standalone dispatchers, instantiating
raw dispatchers without remembering them across recompositions, or attempting to
use non-existent methods like .addChild() breaks hierarchy routing and leaves
child handlers active even when the page is inactive.
// WRONG
@Composable
fun TabPage(isSelected: Boolean) {
val parentDispatcher = LocalNavigationEventDispatcherOwner.current?.navigationEventDispatcher
val childDispatcher = NavigationEventDispatcher() // Unlinked and not remembered across recompositions
// WRONG: Method does not exist
parentDispatcher?.addChild(childDispatcher)
}
You must not bind the same NavigationEventState to multiple active
NavigationBackHandler instances, as this throws an IllegalArgumentException
at runtime. To handle conditional workflows (such as checking for unsaved
changes versus navigating back immediately), you must register a single unified
handler and branch logic inside onBackCompleted.
Why this is RIGHT : Using a single NavigationBackHandler with internal
branching logic inside onBackCompleted maintains a strict 1:1 mapping between
NavigationEventState and the handler, preventing state collisions.
// RIGHT
val navigationState = rememberNavigationEventState(currentInfo = NavigationEventInfo.None)
NavigationBackHandler(
state = navigationState,
isBackEnabled = true,
onBackCompleted = {
if (hasUnsavedChanges) {
showDiscardDialog()
} else {
onNavigateUp()
}
}
)
Why this is WRONG : Attaching multiple NavigationBackHandler composables to
the same navigationState instance attempts to bind duplicate handlers to a
single state object, which throws an IllegalArgumentException at runtime.
// WRONG
val navigationState = rememberNavigationEventState(currentInfo = NavigationEventInfo.None)
NavigationBackHandler(
state = navigationState,
isBackEnabled = hasUnsavedChanges,
onBackCompleted = { /* Discard changes */ }
)
NavigationBackHandler(
state = navigationState,
isBackEnabled = !hasUnsavedChanges,
onBackCompleted = { /* Navigate up */ }
)
For Compose Android targets:
36 or higher? (If compile SDK is lower than 36, set it to 36 or higher in build.gradle.kts).android:enableOnBackInvokedCallback NOT explicitly set to "false" in AndroidManifest.xml? (On API 36+, it defaults to "true"; on API 33--35, ensure it is set to "true").ComponentActivity dispatcher owner without redundant anonymous delegate wrapping?ComponentDialog dispatcher resolution without redundant CompositionLocalProvider wrapping?rememberNavigationEventDispatcherOwner() when managing nested hierarchies?NavigationBackHandler to avoid duplicate registration (IllegalArgumentException)?BackHandler usages migrated to NavigationBackHandler with predictive progress support?references/android/guide/navigation/navigation-event/dispatcher.md (opens in a new tab)references/android/guide/navigation/navigation-event/handle-back.md (opens in a new tab)references/android/guide/navigation/navigation-event/index.md (opens in a new tab)references/android/guide/navigation/navigation-event/setup.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub android/skills --plugin android-skills42 skills in this plugin
/adaptiveInstructions to make or update an app's UI so that it adapts to different Android devices including phones, tablets, foldables, laptops, desktop, TV, Auto, and XR. It includes how to handle different window sizes, pointing devices (such as mouse) and text entry devices (such as keyboard) using the Compose MediaQuery API, and how to preserve UI, navigation, scroll, and media playback state across configuration changes (such as folding/unfolding a foldable, rotating a device, or resizing a window). It also covers multi-pane layouts using Navigation3 Scenes, adaptive UI components (such as buttons) with varying target sizes, and adaptive layouts (including navigation areas - nav rails and nav bars) using the Compose Grid and FlexBox APIs. It also covers desktop experiences with keyboard shortcuts, tooltips and custom cursors./agp-9-upgradeUpgrades, or migrates, an Android project to use Android Gradle Plugin (AGP) version 9. Do not use this skill for migrating Kotlin Multiplatform (KMP) projects./android-cliProvides instructions for installing and using the `android` CLI. The `android` command-line tool is a critical tool for Android development and helps you create new Android projects, install APKs onto devices and emulators and launch and run apps on them, manage and interact with Android virtual devices (including screenshots and UI inspection), manage Android SDK components, inspect built artifacts (APK, AAB, JAR, AAR) for build and optimization details, render Compose previews, look up official Android documentation, and discover and install official Android skills./android-for-cars-parked-appsAdapt existing Android video streaming apps, games, and web browsers to run as parked apps on Android Auto and Android Automotive OS. Covers manifest configuration, Google Play hardware feature declarations, compatibility mode, back navigation affordances, orientation and display continuity, controllable system bar insets, irregular display cutouts, driver distraction lifecycle handling, MediaSession playback restrictions with CarUxRestrictionsManager, background audio while driving, and browser sensitive data protection. Use this skill when migrating, building, or auditing parked apps for cars to meet Car App Quality guidelines. Don't use for media audio apps, templated Car App Library navigation, point of interest, internet of things, weather, or communication apps designed for use while driving./android-intent-securityAudits, detects, and remediates Android Intent and component security vulnerabilities. Use this skill when auditing component configurations in AndroidManifest.xml (activities, services, receivers) or source code handling incoming Intents (getIntent, getParcelableExtra) to prevent Intent Redirection and unauthorized access. Don't use for network security, TLS configuration, or general runtime permission request flows./android-jni-securityAudits, detects, and remediates Android JNI and native C/C++ boundary security vulnerabilities. Use this skill when reviewing, auditing, hardening, or securing Android JNI boundaries, Kotlin external or Java native methods, and C/C++ shared libraries (System.loadLibrary) against buffer overflow, memory pinning, Time-of-Check to Time-of-Use (TOCTOU) file path races, hardcoded C++ cryptographic keys, cross-thread JNI reference and session callback lifecycles, or unhandled pending JVM exceptions and local reference leaks. Don't use for pure managed Kotlin or Java code without native JNI bindings or general reverse-engineering of stripped binaries.3 plugins ship this exact skill · first indexed Sep 8, 2026
Other plugins' skills for the same job