GameActivity Part of Android Game Development Kit.
GameActivity is a Jetpack library designed to assist Android games in
processing app cycle commands, input events, and text input in the application's
GameActivity is a direct descendant of
NativeActivity and shares a similar architecture:
As illustrated in the above diagram,
GameActivity performs the following
- Interacting with Android framework through the Java-side component.
- Passing app cycle commands, input events, and input text to the native side.
- Modelling C/C++ source code into three logical components:
- GameActivity’s JNI functions, which directly support GameActivity’s Java
functionality and enqueue the events to
native_app_glue, which runs mostly in its own native thread (different from the application’s main thread), and executes tasks with its looper.
- The application's game code, which polls and processes the events queued
native_app_glueand executes game code within the
- GameActivity’s JNI functions, which directly support GameActivity’s Java functionality and enqueue the events to
GameActivity, you can focus on your core game development and avoid
spending excessive time dealing with the JNI code.
If you are already familiar with
NativeActivity, the major differences
NativeActivity are as follows:
GameActivityrenders into a
SurfaceView, making it much easier for games to interact with other UI components.
- For touch and key input events,
GameActivityhas a completely new implementation with the
android_input_bufferinterface, separate from the
GameActivityis a derived class of
AppCompatActivity, which lets you seamlessly use other Jetpack components.
Fragment, and others are all available.
GameActivityadds text input functionality by integrating the GameTextInput library.
- Apps derived from
GameActivityare 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_glueand application’s C/C++ code are expected to be built into one library.
NativeActivityis a part of Android framework and follows its release cycle (typically yearly).
GameActivityis 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.
We strongly recommend using
GameActivity for new games and other C/C++
intensive applications. If you have an existing
we recommend migrating.
Follow those guides to integrate
GameActivity into your applications:
To report bugs or request new features to GameActivity, use the GameActivity issue tracker.