1c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner/*
2c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * Copyright (C) 2010 The Android Open Source Project
3c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *
4c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * Licensed under the Apache License, Version 2.0 (the "License");
5c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * you may not use this file except in compliance with the License.
6c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * You may obtain a copy of the License at
7c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *
8c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *      http://www.apache.org/licenses/LICENSE-2.0
9c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner *
10c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * Unless required by applicable law or agreed to in writing, software
11c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * distributed under the License is distributed on an "AS IS" BASIS,
12c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * See the License for the specific language governing permissions and
14c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * limitations under the License.
15c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner */
16c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
17c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
18c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#ifndef ANDROID_NATIVE_ACTIVITY_H
19c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#define ANDROID_NATIVE_ACTIVITY_H
20c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
21c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#include <stdint.h>
22c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#include <sys/types.h>
23c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
24c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner#include <jni.h>
25c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
26956311c6259820b71f3294380cfbce89ac658a93Christopher Tate#include <android/asset_manager.h>
275468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn#include <android/input.h>
2888510488e99d02e3b778ae530bb6e1e6aee3a226Dianne Hackborn#include <android/native_window.h>
295468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn
3090887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner#ifdef __cplusplus
3190887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turnerextern "C" {
3290887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner#endif
33c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
34bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackbornstruct ANativeActivityCallbacks;
35c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
36c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner/**
37c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * This structure defines the native side of an android.app.NativeActivity.
38c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * It is created by the framework, and handed to the application's native
39c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * code as it is being launched.
40c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner */
41bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborntypedef struct ANativeActivity {
42c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
43c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * Pointer to the callback function table of the native application.
44c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * You can set the functions here to your own callbacks.  The callbacks
45c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * pointer itself here should not be changed; it is allocated and managed
46c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * for you by the framework.
47c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
48bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    struct ANativeActivityCallbacks* callbacks;
49c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
50c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
51bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn     * The global handle on the process's Java VM.
52bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn     */
53bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    JavaVM* vm;
54bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn
55bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    /**
56bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn     * JNI context for the main thread of the app.  Note that this field
57bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn     * can ONLY be used from the main thread of the process; that is, the
58bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn     * thread that calls into the ANativeActivityCallbacks.
59c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
60c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    JNIEnv* env;
61bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn
62c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
6325e3c216f2f163c5c7c7923110e2c9cfd76a8d67David 'Digit' Turner     * The NativeActivity object handle.
6425e3c216f2f163c5c7c7923110e2c9cfd76a8d67David 'Digit' Turner     *
6525e3c216f2f163c5c7c7923110e2c9cfd76a8d67David 'Digit' Turner     * IMPORTANT NOTE: This member is mis-named. It should really be named
6625e3c216f2f163c5c7c7923110e2c9cfd76a8d67David 'Digit' Turner     * 'activity' instead of 'clazz', since it's a reference to the
6725e3c216f2f163c5c7c7923110e2c9cfd76a8d67David 'Digit' Turner     * NativeActivity instance created by the system for you.
6825e3c216f2f163c5c7c7923110e2c9cfd76a8d67David 'Digit' Turner     *
6925e3c216f2f163c5c7c7923110e2c9cfd76a8d67David 'Digit' Turner     * We unfortunately cannot change this without breaking NDK
7025e3c216f2f163c5c7c7923110e2c9cfd76a8d67David 'Digit' Turner     * source-compatibility.
71c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
72c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    jobject clazz;
73c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
74c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
7502215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn     * Path to this application's internal data directory.
7602215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn     */
7702215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn    const char* internalDataPath;
7890887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
7902215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn    /**
8002215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn     * Path to this application's external (removable/mountable) data directory.
8102215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn     */
8202215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn    const char* externalDataPath;
8390887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
8402215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn    /**
8502215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn     * The platform's SDK version code.
8602215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn     */
8702215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn    int32_t sdkVersion;
8890887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
8902215b36dde381f0b48ba51bfea405f5a6b01e46Dianne Hackborn    /**
90c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * This is the native instance of the application.  It is not used by
91c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * the framework, but can be set by the application to its own instance
92c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * state.
93c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
94c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    void* instance;
95956311c6259820b71f3294380cfbce89ac658a93Christopher Tate
96956311c6259820b71f3294380cfbce89ac658a93Christopher Tate    /**
97956311c6259820b71f3294380cfbce89ac658a93Christopher Tate     * Pointer to the Asset Manager instance for the application.  The application
98956311c6259820b71f3294380cfbce89ac658a93Christopher Tate     * uses this to access binary assets bundled inside its own .apk file.
99956311c6259820b71f3294380cfbce89ac658a93Christopher Tate     */
100956311c6259820b71f3294380cfbce89ac658a93Christopher Tate    AAssetManager* assetManager;
101bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn} ANativeActivity;
102c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
103c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner/**
104c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * These are the callbacks the framework makes into a native application.
105c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * All of these callbacks happen on the main thread of the application.
106c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * By default, all callbacks are NULL; set to a pointer to your own function
107c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * to have it called.
108c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner */
109bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborntypedef struct ANativeActivityCallbacks {
110c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
111c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * NativeActivity has started.  See Java documentation for Activity.onStart()
112c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * for more information.
113c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
114bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onStart)(ANativeActivity* activity);
11590887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
116c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
117c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * NativeActivity has resumed.  See Java documentation for Activity.onResume()
118c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * for more information.
119c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
120bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onResume)(ANativeActivity* activity);
12190887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
122c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
123c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * Framework is asking NativeActivity to save its current instance state.
124c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * See Java documentation for Activity.onSaveInstanceState() for more
125c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * information.  The returned pointer needs to be created with malloc();
126c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * the framework will call free() on it for you.  You also must fill in
127c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * outSize with the number of bytes in the allocation.  Note that the
128c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * saved state will be persisted, so it can not contain any active
129c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * entities (pointers to memory, file descriptors, etc).
130c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
131bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void* (*onSaveInstanceState)(ANativeActivity* activity, size_t* outSize);
13290887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
133c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
134c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * NativeActivity has paused.  See Java documentation for Activity.onPause()
135c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * for more information.
136c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
137bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onPause)(ANativeActivity* activity);
13890887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
139c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
140c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * NativeActivity has stopped.  See Java documentation for Activity.onStop()
141c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * for more information.
142c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
143bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onStop)(ANativeActivity* activity);
14490887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
145c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
146c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * NativeActivity is being destroyed.  See Java documentation for Activity.onDestroy()
147c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * for more information.
148c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
149bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onDestroy)(ANativeActivity* activity);
150c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
151c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
152c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * Focus has changed in this NativeActivity's window.  This is often used,
153c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * for example, to pause a game when it loses input focus.
154c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
155bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus);
15690887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
157c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
15888510488e99d02e3b778ae530bb6e1e6aee3a226Dianne Hackborn     * The drawing window for this native activity has been created.  You
15988510488e99d02e3b778ae530bb6e1e6aee3a226Dianne Hackborn     * can use the given native window object to start drawing.
160c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
16188510488e99d02e3b778ae530bb6e1e6aee3a226Dianne Hackborn    void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window);
162c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
163c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
16498b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     * The drawing window for this native activity has been resized.  You should
16598b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     * retrieve the new size from the window and ensure that your rendering in
16698b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     * it now matches.
16798b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     */
16898b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    void (*onNativeWindowResized)(ANativeActivity* activity, ANativeWindow* window);
16998b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn
17098b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    /**
17198b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     * The drawing window for this native activity needs to be redrawn.  To avoid
17298b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     * transient artifacts during screen changes (such resizing after rotation),
17398b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     * applications should not return from this function until they have finished
17498b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     * drawing their window in its current state.
17598b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     */
17698b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    void (*onNativeWindowRedrawNeeded)(ANativeActivity* activity, ANativeWindow* window);
17798b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn
17898b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    /**
17988510488e99d02e3b778ae530bb6e1e6aee3a226Dianne Hackborn     * The drawing window for this native activity is going to be destroyed.
18088510488e99d02e3b778ae530bb6e1e6aee3a226Dianne Hackborn     * You MUST ensure that you do not touch the window object after returning
18188510488e99d02e3b778ae530bb6e1e6aee3a226Dianne Hackborn     * from this function: in the common case of drawing to the window from
182c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * another thread, that means the implementation of this callback must
183c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * properly synchronize with the other thread to stop its drawing before
184c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * returning from here.
185c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
18688510488e99d02e3b778ae530bb6e1e6aee3a226Dianne Hackborn    void (*onNativeWindowDestroyed)(ANativeActivity* activity, ANativeWindow* window);
18790887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
1885468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn    /**
1895468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn     * The input queue for this native activity's window has been created.
1905468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn     * You can use the given input queue to start retrieving input events.
1915468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn     */
192bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onInputQueueCreated)(ANativeActivity* activity, AInputQueue* queue);
19390887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
1945468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn    /**
1955468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn     * The input queue for this native activity's window is being destroyed.
1965468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn     * You should no longer try to reference this object upon returning from this
1975468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn     * function.
1985468d768716a4a9de1012067d89908ba4893f9c8Dianne Hackborn     */
199bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue);
200c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
201c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner    /**
20298b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     * The rectangle in the window in which content should be placed has changed.
20398b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn     */
20498b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    void (*onContentRectChanged)(ANativeActivity* activity, const ARect* rect);
20598b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn
20698b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    /**
20779b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn     * The current device AConfiguration has changed.  The new configuration can
20879b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn     * be retrieved from assetManager.
20979b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn     */
21079b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn    void (*onConfigurationChanged)(ANativeActivity* activity);
21179b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn
21279b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn    /**
213c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * The system is running low on memory.  Use this callback to release
214c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * resources you do not need, to help the system avoid killing more
215c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     * important processes.
216c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner     */
217bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn    void (*onLowMemory)(ANativeActivity* activity);
218bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborn} ANativeActivityCallbacks;
219c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
220c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner/**
221c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * This is the function that must be in the native code to instantiate the
222c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * application's native activity.  It is called with the activity instance (see
223c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * above); if the code is being instantiated from a previously saved instance,
22479b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn * the savedState will be non-NULL and point to the saved data.  You must make
22579b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn * any copy of this data you need -- it will be released after you return from
22679b946e8f2ccb552e1a3fe8222f660b9a76cc001Dianne Hackborn * this function.
227c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner */
228bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackborntypedef void ANativeActivity_createFunc(ANativeActivity* activity,
229c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner        void* savedState, size_t savedStateSize);
230c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
231c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner/**
232c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner * The name of the function that NativeInstance looks for when launching its
233a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * native code.  This is the default function that is used, you can specify
234a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * "android.app.func_name" string meta-data in your manifest to use a different
235a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * function.
236c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner */
237bbdfd7c347b4abc5094e890eb1fc2b48d9ff1d95Dianne Hackbornextern ANativeActivity_createFunc ANativeActivity_onCreate;
238c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
239c2d70d2a98f83a655d63c5d7ade5bc05d9f4d4adDianne Hackborn/**
240c2d70d2a98f83a655d63c5d7ade5bc05d9f4d4adDianne Hackborn * Finish the given activity.  Its finish() method will be called, causing it
241a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * to be stopped and destroyed.  Note that this method can be called from
242a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * *any* thread; it will send a message to the main thread of the process
243a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * where the Java finish call will take place.
244c2d70d2a98f83a655d63c5d7ade5bc05d9f4d4adDianne Hackborn */
245c2d70d2a98f83a655d63c5d7ade5bc05d9f4d4adDianne Hackbornvoid ANativeActivity_finish(ANativeActivity* activity);
246c2d70d2a98f83a655d63c5d7ade5bc05d9f4d4adDianne Hackborn
247a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn/**
248a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * Change the window format of the given activity.  Calls getWindow().setFormat()
249a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * of the given activity.  Note that this method can be called from
250a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * *any* thread; it will send a message to the main thread of the process
251a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * where the Java finish call will take place.
252a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn */
2531aa3218800a9d98c7b62450a3821b99b8b9588e0Dianne Hackbornvoid ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format);
2541aa3218800a9d98c7b62450a3821b99b8b9588e0Dianne Hackborn
255a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn/**
256a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * Change the window flags of the given activity.  Calls getWindow().setFlags()
257a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * of the given activity.  Note that this method can be called from
258a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * *any* thread; it will send a message to the main thread of the process
259a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * where the Java finish call will take place.  See window.h for flag constants.
260a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn */
2611aa3218800a9d98c7b62450a3821b99b8b9588e0Dianne Hackbornvoid ANativeActivity_setWindowFlags(ANativeActivity* activity,
2621aa3218800a9d98c7b62450a3821b99b8b9588e0Dianne Hackborn        uint32_t addFlags, uint32_t removeFlags);
2631aa3218800a9d98c7b62450a3821b99b8b9588e0Dianne Hackborn
26498b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn/**
26598b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn * Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager
26698b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn * API for documentation.
26798b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn */
26898b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackbornenum {
26998b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001,
27098b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002,
27198b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn};
27298b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn
273a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn/**
274a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * Show the IME while in the given activity.  Calls InputMethodManager.showSoftInput()
275a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * for the given activity.  Note that this method can be called from
276a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * *any* thread; it will send a message to the main thread of the process
277a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * where the Java finish call will take place.
278a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn */
27998b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackbornvoid ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags);
28098b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn
28198b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn/**
28298b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn * Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager
28398b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn * API for documentation.
28498b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn */
28598b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackbornenum {
28698b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001,
28798b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn    ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002,
28898b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn};
28998b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn
290a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn/**
291a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * Hide the IME while in the given activity.  Calls InputMethodManager.hideSoftInput()
292a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * for the given activity.  Note that this method can be called from
293a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * *any* thread; it will send a message to the main thread of the process
294a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn * where the Java finish call will take place.
295a77c1bdd4abf3c7e82af1f3b4330143d14c84103Dianne Hackborn */
29698b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackbornvoid ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags);
29798b2c359c2b3361f43e14b0c5d07a02c055dd10eDianne Hackborn
29890887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner#ifdef __cplusplus
29990887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner};
30090887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner#endif
30190887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner
30290887627f185ea795fd8620bb916bd14a9f51041David 'Digit' Turner#endif // ANDROID_NATIVE_ACTIVITY_H
303c817c5210e4207908b83faaf08a2c5b95251f871David 'Digit' Turner
304