# 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/structandroid/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/structandroid/app#structandroid__app_1aa7ec7147572780debc989a1d4d175383` | `int` Current state of the app's activity. |
| `https://developer.android.com/reference/games/game-activity/structandroid/app#structandroid__app_1a213d5969dfae6fc952d2c6dc10077066` | `AConfiguration *` The current configuration the app is running in. |
| `https://developer.android.com/reference/games/game-activity/structandroid/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/structandroid/app#structandroid__app_1a0bb6a9a8909689a706e8e30ba3bc821e` | `int` |
| `https://developer.android.com/reference/games/game-activity/structandroid/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/structandroid/app#structandroid__app_1a0a3c227ec44218dec3b80f24f39b4884[NATIVE_APP_GLUE_MAX_INPUT_BUFFERS]` | `struct https://developer.android.com/reference/games/game-activity/structandroid/input-buffer#structandroid__input__buffer` This is used for buffering input from [GameActivity](https://developer.android.com/reference/games/game-activity/struct/game-activity#struct_game_activity). |
| `https://developer.android.com/reference/games/game-activity/structandroid/app#structandroid__app_1aacbfb39562eb5b5386e9affb2e5c852a` | `ALooper *` The ALooper associated with the app's thread. |
| `https://developer.android.com/reference/games/game-activity/structandroid/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/structandroid/app#structandroid__app_1a25fd3ec42798fb7cffc243502b35a5e3` | `void *` The last activity saved state, as provided at creation time. |
| `https://developer.android.com/reference/games/game-activity/structandroid/app#structandroid__app_1a2194e58c113f617e474728d15193e4e1` | `size_t` The size of the activity saved state. |
| `https://developer.android.com/reference/games/game-activity/structandroid/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/structandroid/app#structandroid__app_1a7db5bcb24a007843cd551d94f90b6a83` | `void *` An optional pointer to application-defined state. |
| `https://developer.android.com/reference/games/game-activity/structandroid/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.

### currentInputBuffer

```scdoc
int android_app::currentInputBuffer
```

### 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.

### inputBuffers

```transact-sql
struct android_input_buffer android_app::inputBuffers[NATIVE_APP_GLUE_MAX_INPUT_BUFFERS]
```
This is used for buffering input from [GameActivity](https://developer.android.com/reference/games/game-activity/struct/game-activity#struct_game_activity).

Once ready, the application thread switches the buffers and processes what was accumulated.

### looper

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

### 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.