본문으로 건너뛰기
Skillpedia
모바일 앱10k · #11925

navigation-event

하는 일

이 스킬은 Jetpack Compose Android 앱에서 뒤로 가기 제스처를 가로채고 예측형 뒤로 가기 애니메이션을 실행하는 방법을 안내합니다. 탭 같은 중첩 컨테이너와 기존 BackHandler에서 옮기는 방법도 다룹니다. 맞춤 뒤로 가기 동작이 필요한 Android 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓Compose 화면에서 뒤로 가기 제스처를 가로채야 할 때.
  • ✓Android 앱에 예측형 뒤로 가기 애니메이션을 넣고 싶을 때.
  • ✓오래된 BackHandler 코드를 NavigationEvent 라이브러리로 옮겨야 할 때.

스킬 링크

https://github.com/android/skills/blob/main/navigation/navigation-event/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/android/skills/blob/main/navigation/navigation-event/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“내 Compose 앱에서 뒤로 가기 제스처를 예측형 애니메이션과 함께 쓰고, 먼저 바텀 시트를 닫게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 액티비티의 디스패처와 Compose 뒤로 가기 핸들러를 설정하고, 각각을 맞는 화면, 탭, 대화상자에 한정합니다. 최신 Android 버전에서 기존 BackHandler 코드를 옮기는 방법도 다룹니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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 36 or higher in build.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 : ComponentActivity automatically implements NavigationEventDispatcherOwner out-of-the-box. You must use the built-in navigationEventDispatcher without creating anonymous delegate owners or overriding member properties.
  • For dialog scoping : Floating windows (Compose Dialog, ModalBottomSheet, ComponentDialog) automatically provide a NavigationEventDispatcherOwner. You don't need manual CompositionLocalProvider propagation for dialogs.
  • For parent-child dispatcher hierarchies : When scoping navigation handling to 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.
  • For Compose handlers : A one-to-one relationship between NavigationEventState and handlers is strictly enforced. Never bind the same NavigationEventState to multiple active NavigationBackHandler instances (IllegalArgumentException).

Step 1: Plan

To complete this step, you MUST ensure the following:

  1. Identify the target platform : Verify the app is targeting Compose Android. If compileSdk is lower than 36, set it to 36 or higher in build.gradle.kts.
  2. 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.
  3. Hierarchy check : Identify host Activities, ViewPagers, tabbed interfaces, or nested navigation hosts that require back gesture interception or parent-child dispatcher linking.
  4. Migration check : Check if the project is migrating from back handling (OnBackPressedCallback, BackHandler, onBackPresser) to NavigationEvent and NavigationBackHandler.
  5. 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 ComponentActivity or ComponentDialog owner 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 NavigationBackHandler and rememberNavigationEventDispatcherOwner(), 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 = false to 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

자주 묻는 질문

Android Views 앱에도 작동하나요?

아니요. 이 스킬은 Compose Android 앱만 대상으로 하며 Views는 제외됩니다.

필요한 Android 대상 버전은 무엇인가요?

앱의 compile SDK가 36보다 낮으면 스킬이 36 이상으로 올립니다.

대화상자에 추가 설정이 필요한가요?

아니요. 대화상자와 바텀 시트는 자체 디스패처를 제공하므로 추가 연결이 필요하지 않습니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
10k
순위
#11925
라이선스
Apache-2.0
업데이트
2026. 10. 29.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬