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.
destroyRequested
int
This is non-zero when the application's GameActivity is being destroyed and waiting for the app thread to complete.
keyDownEvents[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS]
Pointer to a read-only array of pointers GameActivityKeyEvent.
keyDownEventsCount
uint64_t
The number of valid "Key Down" events in keyDownEvents.
keyUpEvents[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS]
Pointer to a read-only array of pointers to GameActivityKeyEvent.
keyUpEventsCount
uint64_t
The number of valid "Key Up" events in keyUpEvents.
looper
ALooper *
The ALooper associated with the app's thread.
motionEvents[NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS]
Pointer to a read-only array of pointers to GameActivityMotionEvent.
motionEventsCount
uint64_t
The number of valid motion events in motionEvents.
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

activity

GameActivity * android_app::activity

The GameActivity object instance that this app is running in.

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.

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.

keyDownEvents

GameActivityKeyEvent android_app::keyDownEvents[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS]

Pointer to a read-only array of pointers GameActivityKeyEvent.

Only the first keyDownEventsCount events are valid.

keyDownEventsCount

uint64_t android_app::keyDownEventsCount

The number of valid "Key Down" events in keyDownEvents.

keyUpEvents

GameActivityKeyEvent android_app::keyUpEvents[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS]

Pointer to a read-only array of pointers to GameActivityKeyEvent.

Only the first keyUpEventsCount events are valid.

keyUpEventsCount

uint64_t android_app::keyUpEventsCount

The number of valid "Key Up" events in keyUpEvents.

looper

ALooper * android_app::looper

The ALooper associated with the app's thread.

motionEvents

GameActivityMotionEvent android_app::motionEvents[NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS]

Pointer to a read-only array of pointers to GameActivityMotionEvent.

Only the first motionEventsCount events are valid.

motionEventsCount

uint64_t android_app::motionEventsCount

The number of valid motion events in motionEvents.

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.