# 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 ||
|---|---|
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1aef0d97c0a88bf41760af33bcaf118e1a` | `https://developer.android.com/reference/games/game-activity/struct/game-activity#struct_game_activity *` The [GameActivity](https://developer.android.com/reference/games/game-activity/struct/game-activity#struct_game_activity) object instance that this app is running in. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1aa7ec7147572780debc989a1d4d175383` | `int` Current state of the app's activity. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a213d5969dfae6fc952d2c6dc10077066` | `AConfiguration *` The current configuration the app is running in. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#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. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a28aec6ab9685d0cba4a1fcb2fb78ea99` | `int` This is non-zero when the application's [GameActivity](https://developer.android.com/reference/games/game-activity/struct/game-activity#struct_game_activity) is being destroyed and waiting for the app thread to complete. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a8126c801d32b159b9bac2b6b841ddd3f[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS]` | `https://developer.android.com/reference/games/game-activity/struct/game-activity-key-event#struct_game_activity_key_event` Pointer to a read-only array of pointers [GameActivityKeyEvent](https://developer.android.com/reference/games/game-activity/struct/game-activity-key-event#struct_game_activity_key_event). |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1abe2340570b88767d92a278f60684123d` | `uint64_t` The number of valid "Key Down" events in `keyDownEvents`. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a712797395a3b5a229f1cb905e7a8d9ac[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS]` | `https://developer.android.com/reference/games/game-activity/struct/game-activity-key-event#struct_game_activity_key_event` Pointer to a read-only array of pointers to [GameActivityKeyEvent](https://developer.android.com/reference/games/game-activity/struct/game-activity-key-event#struct_game_activity_key_event). |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a7cd6784c941a7399aab0527fa1c4f1d2` | `uint64_t` The number of valid "Key Up" events in `keyUpEvents`. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1aacbfb39562eb5b5386e9affb2e5c852a` | `ALooper *` The ALooper associated with the app's thread. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a5faed942d57386a844fad12034b03129[NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS]` | `https://developer.android.com/reference/games/game-activity/struct/game-activity-motion-event#struct_game_activity_motion_event` Pointer to a read-only array of pointers to [GameActivityMotionEvent](https://developer.android.com/reference/games/game-activity/struct/game-activity-motion-event#struct_game_activity_motion_event). |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1ac1c66590b95f4ff86b8747023cdb3d6f` | `uint64_t` The number of valid motion events in `motionEvents`. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1aba9f81527b0c5c5ec27a9736b0f49dca)(struct android_app *app, int32_t cmd)` | `void(*` A required callback for processing main app commands (`APP_CMD_*`). |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a25fd3ec42798fb7cffc243502b35a5e3` | `void *` The last activity saved state, as provided at creation time. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a2194e58c113f617e474728d15193e4e1` | `size_t` The size of the activity saved state. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1ab2b313eab892f533444bb9b3d117130a` | `int` 0 if no text input event is outstanding, 1 if it is. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a7db5bcb24a007843cd551d94f90b6a83` | `void *` An optional pointer to application-defined state. |
| `https://developer.android.com/reference/games/game-activity/struct/android-app#structandroid__app_1a7a0fd7c92b854bd467d982bddd7b7db8` | `ANativeWindow *` When non-NULL, this is the window surface that the app can draw in. |

## Public attributes

### activity

```scdoc
GameActivity * android_app::activity
```
The [GameActivity](https://developer.android.com/reference/games/game-activity/struct/game-activity#struct_game_activity) object instance that this app is running in.

### activityState

```scdoc
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

```scdoc
AConfiguration * android_app::config
```
The current configuration the app is running in.

### contentRect

```scdoc
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.

### destroyRequested

```scdoc
int android_app::destroyRequested
```
This is non-zero when the application's [GameActivity](https://developer.android.com/reference/games/game-activity/struct/game-activity#struct_game_activity) is being destroyed and waiting for the app thread to complete.

### keyDownEvents

```transact-sql
GameActivityKeyEvent android_app::keyDownEvents[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS]
```
Pointer to a read-only array of pointers [GameActivityKeyEvent](https://developer.android.com/reference/games/game-activity/struct/game-activity-key-event#struct_game_activity_key_event).

Only the first keyDownEventsCount events are valid.

### keyDownEventsCount

```scdoc
uint64_t android_app::keyDownEventsCount
```
The number of valid "Key Down" events in `keyDownEvents`.

### keyUpEvents

```transact-sql
GameActivityKeyEvent android_app::keyUpEvents[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS]
```
Pointer to a read-only array of pointers to [GameActivityKeyEvent](https://developer.android.com/reference/games/game-activity/struct/game-activity-key-event#struct_game_activity_key_event).

Only the first keyUpEventsCount events are valid.

### keyUpEventsCount

```scdoc
uint64_t android_app::keyUpEventsCount
```
The number of valid "Key Up" events in `keyUpEvents`.

### looper

```scdoc
ALooper * android_app::looper
```
The ALooper associated with the app's thread.

### motionEvents

```transact-sql
GameActivityMotionEvent android_app::motionEvents[NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS]
```
Pointer to a read-only array of pointers to [GameActivityMotionEvent](https://developer.android.com/reference/games/game-activity/struct/game-activity-motion-event#struct_game_activity_motion_event).

Only the first motionEventsCount events are valid.

### motionEventsCount

```scdoc
uint64_t android_app::motionEventsCount
```
The number of valid motion events in `motionEvents`.

### onAppCmd

```scdoc
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

```scdoc
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

```scdoc
size_t android_app::savedStateSize
```
The size of the activity saved state.

It is 0 if `savedState` is NULL.

### textInputState

```scdoc
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

```scdoc
void * android_app::userData
```
An optional pointer to application-defined state.

### window

```scdoc
ANativeWindow * android_app::window
```
When non-NULL, this is the window surface that the app can draw in.