GameActivity는 애플리케이션의 C/C++ 코드에서 앱 주기 명령어, 입력 이벤트, 텍스트 입력을 처리하는 데 있어 Android 게임을 지원하도록 설계된 Jetpack 라이브러리입니다. GameActivity는 NativeActivity의 직접적인 하위 요소이며 유사한 아키텍처를 공유합니다.
위의 다이어그램과 같이 GameActivity는 다음 기능을 실행합니다.
자바 측 구성요소를 통해 Android 프레임워크와 상호작용
앱 주기 명령어, 입력 이벤트, 입력 텍스트를 네이티브 측에 전달
C/C++ 소스 코드를 다음 세 가지 논리적 구성요소로 모델링
GameActivity의 JNI 함수. GameActivity의 자바 기능을 직접 지원하고 이벤트를 native_app_glue의 대기열에 추가합니다.
native_app_glue. 자체 네이티브 스레드(애플리케이션의 기본 스레드와 다름)에서 대부분 실행되고 루퍼로 작업을 실행합니다.
애플리케이션의 게임 코드. native_app_glue 내에서 대기열에 추가된 이벤트를 폴링하고 처리하며 native_app_glue 스레드 내에서 게임 코드를 실행합니다.
GameActivity를 사용하면 핵심 게임 개발에 집중할 수 있고 JNI 코드를 처리하는 데 과도한 시간을 소비하지 않아도 됩니다.
NativeActivity에 이미 익숙하다면 GameActivity와 NativeActivity의 주요 차이점은 다음과 같습니다.
GameActivity는 SurfaceView로 렌더링되므로 게임이 다른 UI 구성요소와 훨씬 더 쉽게 상호작용할 수 있습니다.
터치 및 키 입력 이벤트의 경우 GameActivity에는 NativeActivity에서 사용하는 InputQueue와는 별도로 android_input_buffer 인터페이스를 사용하는 완전히 새로운 구현이 있습니다.
GameActivity는 AppCompatActivity의 파생 클래스로, 다른 Jetpack 구성요소를 원활하게 사용할 수 있도록 합니다.
ActionBar, Fragment 등을 모두 사용할 수 있습니다.
GameActivity에서 파생된 앱은 C/C++ 코드의 세 가지 부분을 모두 라이브러리 하나에 빌드해야 합니다. 반면 NativeActivity의 JNI 함수는 프레임워크의 일부입니다(항상 OS에 의해 로드됨). 따라서 native_app_glue와 애플리케이션의 C/C++ 코드만 라이브러리 하나에 빌드되어야 합니다.
NativeActivity는 Android 프레임워크의 일부이며 출시 주기(일반적으로 연간)를 따릅니다. GameActivity는 출시 주기(일반적으로 격주)가 훨씬 더 잦은 Jetpack 라이브러리의 일부입니다. 새로운 기능과 버그 수정이 훨씬 빠르게 제공될 수 있습니다.
C/C++ 코드는 모든 출시 채널에서 Prefab 형식을 사용하여 소스 코드로 제공됩니다. GameActivity 버전 1.2.2는 정적 라이브러리를 배포에 추가합니다.
이 버전부터는 소스 코드 대신 정적 라이브러리를 사용하는 것이 좋습니다.
Jetpack 라이브러리 및 AGDK zip 패키지의 내용
Jetpack 라이브러리와 AGDK zip 패키지 채널에서 GameActivity는 AAR과 함께 출시됩니다. 이 AAR은 다음과 같은 주요 요소로 구성되어 있습니다.
자바 코드용 JAR 파일
C/C++ 정적 라이브러리 game-activity_static. GameActivity 버전 1.2.2 이상에 포함되어 있습니다.
C/C++ 소스 코드(/prefab 폴더 아래)
이 페이지에서 연결된 통합 안내에서는 개발자가 빌드 시스템에서 Prefab를 사용할 수 있다고 가정합니다. 그러지 않은 경우에는 prefab/modules/game-activity/include 폴더에 포함된 소스 코드를 빌드 시스템에 복사하여 필요한 통합 단계를 실행할 수 있습니다. Android Jetpack 라이브러리의 androidx 아래에 버전과 관련된 유사한 파일 구조가 있습니다. 기본적으로 Gradle은 캐시 디렉터리(~/.gradle/caches/...)에 AAR의 압축을 해제합니다. C/C++ 소스 코드는 prefab/modules/game-activity/include를 검색하고 원하는 출시 버전에서 위치를 선택하여 찾을 수 있습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-26(UTC)
[null,null,["최종 업데이트: 2025-08-26(UTC)"],[],[],null,["GameActivity\nPart of [Android Game Development Kit](/games/agdk/overview).\n\n[`GameActivity`](/reference/games/game-activity) is a Jetpack library designed\nto assist Android games in processing app cycle commands, input events, and text\ninput in the application's C/C++ code. `GameActivity` is a direct descendant of\n[`NativeActivity`](/reference/android/app/NativeActivity) and shares a similar\narchitecture:\n\nAs illustrated in the above diagram, `GameActivity` performs the following\nfunctions:\n\n- Interacting with Android framework through the Java-side component.\n- Passing app cycle commands, input events, and input text to the native side.\n- Modelling C/C++ source code into three logical components:\n - GameActivity's JNI functions, which directly support GameActivity's Java functionality and enqueue the events to `native_app_glue`.\n - `native_app_glue`, which runs mostly in its own native thread (different from the application's main thread), and executes tasks with its looper.\n - The application's game code, which polls and processes the events queued inside `native_app_glue` and executes game code within the `native_app_glue` thread.\n\nWith `GameActivity`, you can focus on your core game development and avoid\nspending excessive time dealing with the JNI code.\n\nIf you are already familiar with `NativeActivity`, the major differences\nbetween `GameActivity` and `NativeActivity` are as follows:\n\n- `GameActivity` renders into a [`SurfaceView`](/reference/android/view/SurfaceView), making it much easier for games to interact with other UI components.\n- For touch and key input events, `GameActivity` has a completely new implementation with the [`android_input_buffer`](/reference/games/game-activity/structandroid/input-buffer) interface, separate from the [`InputQueue`](/reference/android/view/InputQueue) that `NativeActivity` uses.\n- `GameActivity` is a derived class of `AppCompatActivity`, which lets you seamlessly use other Jetpack components. [`ActionBar`](/reference/android/app/ActionBar), [`Fragment`](/guide/fragments), and others are all available.\n- `GameActivity` adds text input functionality by integrating [the\n GameTextInput library](/games/agdk/add-support-for-text-input).\n- Apps derived from `GameActivity` are expected to build all three parts of C/C++ code into one library. On the other hand, `NativeActivity`'s JNI functions are a part of the framework (always loaded by OS). Hence, only the `native_app_glue` and application's C/C++ code are expected to be built into one library.\n- `NativeActivity` is a part of Android framework and follows its release cycle (typically yearly). `GameActivity` is a part of the Jetpack library, which has a much more frequent release cycle (typically biweekly); new features and bug fixes can arrive much more quickly.\n\n| **Note:** We strongly recommend using `GameActivity` for new games and other C/C++ intensive applications. If you have an existing `NativeActivity` application, we recommend migrating to `GameActivity`.\n\nRelease locations\n\nThe `GameActivity` library is available in the following channels:\n\n- As a part of the [Android Jetpack library](/jetpack/androidx/releases/games) (recommended)\n- As [AOSP](https://android.googlesource.com/platform/frameworks/opt/gamesdk/) source code\n\nThe C/C++ code is provided as source code in all release channels, using the\n[Prefab](/studio/build/dependencies?agpversion=4.0#native-dependencies-aars)\nformat. GameActivity version 1.2.2 adds a static library to the distribution.\nStarting with this version and later, we recommend you use the static library\ninstead of the source code.\n| **Note:** Most of the documentation on this site is written from the perspective of AndroidX.\n\nContents of Jetpack library and AGDK zip package\n\nWith the Jetpack library and AGDK zip package channels, GameActivity is released\nwith an AAR. This AAR contains the following major components:\n\n- A JAR file for Java code\n- The C/C++static library `game-activity_static` is included with GameActivity version 1.2.2 and later.\n- C/C++ source code (under the `/prefab` folder)\n\nThe integration instructions linked to from this page assume that you can use\nPrefab in your build system; otherwise, you can copy the source code packed\nunder the `prefab/modules/game-activity/include` folder into your build system\nand perform the necessary integration steps. A similar file structure exists for\nthe releases under `androidx` for the Android Jetpack library; by default,\ngradle unpacks AARs in its cache directory (\\~/.gradle/caches/...). You can find\nthe C/C++ source code by searching for `prefab/modules/game-activity/include`\nand picking up the location under your intended release version.\n\nFor instructions on integrating using the Jetpack library, see\n[Get started with GameActivity](/games/agdk/game-activity/get-started).\n\nContent of AOSP source code\n\nAOSP always contains the most recent source code. Follow [the build\ninstructions](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/GameActivity/) to create your own releases or directly integrate the source into\nyour build environment. The C/C++ source code is saved in a file structure\nsimilar to the ones for the Jetpack library and AGDK zip package.\n\nIntegration guides\n\nFollow those guides to integrate `GameActivity` into your applications:\n\n- [Get started](/games/agdk/game-activity/get-started)\n- [Use game text input](/games/agdk/game-activity/use-text-input)\n- [NativeActivity migration guide](/games/agdk/game-activity/migrate-native-activity)\n\nAdditional resources\n\nTo learn more about `GameActivity`, see the following:\n\n- [GameActivity and AGDK release notes](/games/agdk/release-notes).\n- [Use GameTextInput in GameActivity](/games/agdk/game-activity/use-text-input).\n- [NativeActivity migration guide](/games/agdk/game-activity/migrate-native-activity).\n- [GameActivity reference documentation](/reference/games/game-activity/group/game-activity).\n- [GameActivity implementation](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/game-activity/).\n\nFeedback\n\nTo report bugs or request new features to GameActivity, use\n[the GameActivity issue tracker](https://issuetracker.google.com/issues/new?component=897320&template=1456805)."]]