Stay organized with collections
Save and categorize content based on your preferences.
android_app
#include <android_native_app_glue.h>
This is the interface for the standard glue code of a threaded application.
Summary
In this model, the application's code is running in its own thread separate from the main thread of the process. It is not required that this thread be associated with the Java VM, although it will need to be in order to make JNI calls any Java objects.
Public attributes
|
activity
|
The GameActivity object instance that this app is running in.
|
activityState
|
int
Current state of the app's activity.
|
config
|
AConfiguration *
The current configuration the app is running in.
|
contentRect
|
ARect
Current content rectangle of the window; this is the area where the window's content should be placed to be seen by the user.
|
currentInputBuffer
|
int
|
destroyRequested
|
int
This is non-zero when the application's GameActivity is being destroyed and waiting for the app thread to complete.
|
inputBuffers[NATIVE_APP_GLUE_MAX_INPUT_BUFFERS]
|
|
looper
|
ALooper *
The ALooper associated with the app's thread.
|
onAppCmd)(struct android_app *app, int32_t cmd)
|
void(*
A required callback for processing main app commands (APP_CMD_* ).
|
savedState
|
void *
The last activity saved state, as provided at creation time.
|
savedStateSize
|
size_t
The size of the activity saved state.
|
textInputState
|
int
0 if no text input event is outstanding, 1 if it is.
|
userData
|
void *
An optional pointer to application-defined state.
|
window
|
ANativeWindow *
When non-NULL, this is the window surface that the app can draw in.
|
Public attributes
activityState
int android_app::activityState
Current state of the app's activity.
May be either APP_CMD_START, APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP.
config
AConfiguration * android_app::config
The current configuration the app is running in.
contentRect
ARect android_app::contentRect
Current content rectangle of the window; this is the area where the window's content should be placed to be seen by the user.
int android_app::currentInputBuffer
destroyRequested
int android_app::destroyRequested
This is non-zero when the application's GameActivity is being destroyed and waiting for the app thread to complete.
struct android_input_buffer android_app::inputBuffers[NATIVE_APP_GLUE_MAX_INPUT_BUFFERS]
This is used for buffering input from GameActivity.
Once ready, the application thread switches the buffers and processes what was accumulated.
looper
ALooper * android_app::looper
The ALooper associated with the app's thread.
onAppCmd
void(* android_app::onAppCmd)(struct android_app *app, int32_t cmd)
A required callback for processing main app commands (APP_CMD_*
).
This is called each frame if there are app commands that need processing.
savedState
void * android_app::savedState
The last activity saved state, as provided at creation time.
It is NULL if there was no state. You can use this as you need; the memory will remain around until you call android_app_exec_cmd() for APP_CMD_RESUME, at which point it will be freed and savedState set to NULL. These variables should only be changed when processing a APP_CMD_SAVE_STATE, at which point they will be initialized to NULL and you can malloc your state and place the information here. In that case the memory will be freed for you later.
savedStateSize
size_t android_app::savedStateSize
The size of the activity saved state.
It is 0 if savedState
is NULL.
textInputState
int android_app::textInputState
0 if no text input event is outstanding, 1 if it is.
Use GameActivity_getTextInputState
to get information about the text entered by the user.
userData
void * android_app::userData
An optional pointer to application-defined state.
window
ANativeWindow * android_app::window
When non-NULL, this is the window surface that the app can draw in.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-03-15 UTC.
[null,null,["Last updated 2022-03-15 UTC."],[],[],null,["# android_app Struct Reference\n\nandroid_app\n===========\n\n`#include \u003candroid_native_app_glue.h\u003e`\n\nThis is the interface for the standard glue code of a threaded application.\n\nSummary\n-------\n\nIn this model, the application's code is running in its own thread separate from the main thread of the process. It is not required that this thread be associated with the Java VM, although it will need to be in order to make JNI calls any Java objects.\n\n| ### Public attributes ||\n|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [activity](#structandroid__app_1aef0d97c0a88bf41760af33bcaf118e1a) | [GameActivity](/reference/games/game-activity/struct/game-activity#struct_game_activity)` *` The [GameActivity](/reference/games/game-activity/struct/game-activity#struct_game_activity) object instance that this app is running in. |\n| [activityState](#structandroid__app_1aa7ec7147572780debc989a1d4d175383) | `int` Current state of the app's activity. |\n| [config](#structandroid__app_1a213d5969dfae6fc952d2c6dc10077066) | `AConfiguration *` The current configuration the app is running in. |\n| [contentRect](#structandroid__app_1a8502b9a38db281f86421191fba5e82ab) | `ARect` Current content rectangle of the window; this is the area where the window's content should be placed to be seen by the user. |\n| [currentInputBuffer](#structandroid__app_1a0bb6a9a8909689a706e8e30ba3bc821e) | `int` |\n| [destroyRequested](#structandroid__app_1a28aec6ab9685d0cba4a1fcb2fb78ea99) | `int` This is non-zero when the application's [GameActivity](/reference/games/game-activity/struct/game-activity#struct_game_activity) is being destroyed and waiting for the app thread to complete. |\n| [inputBuffers](#structandroid__app_1a0a3c227ec44218dec3b80f24f39b4884)`[NATIVE_APP_GLUE_MAX_INPUT_BUFFERS]` | `struct `[android_input_buffer](/reference/games/game-activity/structandroid/input-buffer#structandroid__input__buffer) This is used for buffering input from [GameActivity](/reference/games/game-activity/struct/game-activity#struct_game_activity). |\n| [looper](#structandroid__app_1aacbfb39562eb5b5386e9affb2e5c852a) | `ALooper *` The ALooper associated with the app's thread. |\n| [onAppCmd](#structandroid__app_1aba9f81527b0c5c5ec27a9736b0f49dca)`)(struct android_app *app, int32_t cmd)` | `void(*` A required callback for processing main app commands (`APP_CMD_*`). |\n| [savedState](#structandroid__app_1a25fd3ec42798fb7cffc243502b35a5e3) | `void *` The last activity saved state, as provided at creation time. |\n| [savedStateSize](#structandroid__app_1a2194e58c113f617e474728d15193e4e1) | `size_t` The size of the activity saved state. |\n| [textInputState](#structandroid__app_1ab2b313eab892f533444bb9b3d117130a) | `int` 0 if no text input event is outstanding, 1 if it is. |\n| [userData](#structandroid__app_1a7db5bcb24a007843cd551d94f90b6a83) | `void *` An optional pointer to application-defined state. |\n| [window](#structandroid__app_1a7a0fd7c92b854bd467d982bddd7b7db8) | `ANativeWindow *` When non-NULL, this is the window surface that the app can draw in. |\n\nPublic attributes\n-----------------\n\n### activity\n\n```scdoc\nGameActivity * android_app::activity\n``` \nThe [GameActivity](/reference/games/game-activity/struct/game-activity#struct_game_activity) object instance that this app is running in. \n\n### activityState\n\n```scdoc\nint android_app::activityState\n``` \nCurrent state of the app's activity.\n\nMay be either APP_CMD_START, APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP. \n\n### config\n\n```scdoc\nAConfiguration * android_app::config\n``` \nThe current configuration the app is running in. \n\n### contentRect\n\n```scdoc\nARect android_app::contentRect\n``` \nCurrent content rectangle of the window; this is the area where the window's content should be placed to be seen by the user. \n\n### currentInputBuffer\n\n```scdoc\nint android_app::currentInputBuffer\n``` \n\n### destroyRequested\n\n```scdoc\nint android_app::destroyRequested\n``` \nThis is non-zero when the application's [GameActivity](/reference/games/game-activity/struct/game-activity#struct_game_activity) is being destroyed and waiting for the app thread to complete. \n\n### inputBuffers\n\n```transact-sql\nstruct android_input_buffer android_app::inputBuffers[NATIVE_APP_GLUE_MAX_INPUT_BUFFERS]\n``` \nThis is used for buffering input from [GameActivity](/reference/games/game-activity/struct/game-activity#struct_game_activity).\n\nOnce ready, the application thread switches the buffers and processes what was accumulated. \n\n### looper\n\n```scdoc\nALooper * android_app::looper\n``` \nThe ALooper associated with the app's thread. \n\n### onAppCmd\n\n```scdoc\nvoid(* android_app::onAppCmd)(struct android_app *app, int32_t cmd)\n``` \nA required callback for processing main app commands (`APP_CMD_*`).\n\nThis is called each frame if there are app commands that need processing. \n\n### savedState\n\n```scdoc\nvoid * android_app::savedState\n``` \nThe last activity saved state, as provided at creation time.\n\nIt is NULL if there was no state. You can use this as you need; the memory will remain around until you call android_app_exec_cmd() for APP_CMD_RESUME, at which point it will be freed and savedState set to NULL. These variables should only be changed when processing a APP_CMD_SAVE_STATE, at which point they will be initialized to NULL and you can malloc your state and place the information here. In that case the memory will be freed for you later. \n\n### savedStateSize\n\n```scdoc\nsize_t android_app::savedStateSize\n``` \nThe size of the activity saved state.\n\nIt is 0 if `savedState` is NULL. \n\n### textInputState\n\n```scdoc\nint android_app::textInputState\n``` \n0 if no text input event is outstanding, 1 if it is.\n\nUse `GameActivity_getTextInputState` to get information about the text entered by the user. \n\n### userData\n\n```scdoc\nvoid * android_app::userData\n``` \nAn optional pointer to application-defined state. \n\n### window\n\n```scdoc\nANativeWindow * android_app::window\n``` \nWhen non-NULL, this is the window surface that the app can draw in."]]