1e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/* 2e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Copyright (C) 2010 The Android Open Source Project 3e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * 4e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 5e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * you may not use this file except in compliance with the License. 6e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * You may obtain a copy of the License at 7e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * 8e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 9e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * 10e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Unless required by applicable law or agreed to in writing, software 11e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 12e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * See the License for the specific language governing permissions and 14e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * limitations under the License. 15e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 16e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 17e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 18e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifndef ANDROID_NATIVE_ACTIVITY_H 19e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#define ANDROID_NATIVE_ACTIVITY_H 20e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 21e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <stdint.h> 22e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <sys/types.h> 23e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 24e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <jni.h> 25e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 26e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <android/asset_manager.h> 27e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <android/input.h> 28e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <android/native_window.h> 29e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 30e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifdef __cplusplus 31e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianextern "C" { 32e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif 33e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 34e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianstruct ANativeActivityCallbacks; 35e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 36e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 37e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * This structure defines the native side of an android.app.NativeActivity. 38e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * It is created by the framework, and handed to the application's native 39e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * code as it is being launched. 40e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 41e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef struct ANativeActivity { 42e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 43e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Pointer to the callback function table of the native application. 44e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * You can set the functions here to your own callbacks. The callbacks 45e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * pointer itself here should not be changed; it is allocated and managed 46e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for you by the framework. 47e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 48e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian struct ANativeActivityCallbacks* callbacks; 49e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 50e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 51e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The global handle on the process's Java VM. 52e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 53e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian JavaVM* vm; 54e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 55e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 56e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * JNI context for the main thread of the app. Note that this field 57e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * can ONLY be used from the main thread of the process; that is, the 58e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * thread that calls into the ANativeActivityCallbacks. 59e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 60e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian JNIEnv* env; 61e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 62e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 63e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The NativeActivity object handle. 64e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * 65e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * IMPORTANT NOTE: This member is mis-named. It should really be named 66e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * 'activity' instead of 'clazz', since it's a reference to the 67e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * NativeActivity instance created by the system for you. 68e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * 69e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * We unfortunately cannot change this without breaking NDK 70e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * source-compatibility. 71e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 72e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian jobject clazz; 73e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 74e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 75e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Path to this application's internal data directory. 76e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 77e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian const char* internalDataPath; 78e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 79e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 80e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Path to this application's external (removable/mountable) data directory. 81e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 82e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian const char* externalDataPath; 83e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 84e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 85e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The platform's SDK version code. 86e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 87e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian int32_t sdkVersion; 88e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 89e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 90e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * This is the native instance of the application. It is not used by 91e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * the framework, but can be set by the application to its own instance 92e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * state. 93e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 94e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void* instance; 95e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 96e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 97e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Pointer to the Asset Manager instance for the application. The application 98e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * uses this to access binary assets bundled inside its own .apk file. 99e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 100e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian AAssetManager* assetManager; 101e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 102e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 103e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Available starting with Honeycomb: path to the directory containing 104e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * the application's OBB files (if any). If the app doesn't have any 105e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * OBB files, this directory may not exist. 106e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 107e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian const char* obbPath; 108e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian} ANativeActivity; 109e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 110e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 111e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * These are the callbacks the framework makes into a native application. 112e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * All of these callbacks happen on the main thread of the application. 113e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * By default, all callbacks are NULL; set to a pointer to your own function 114e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * to have it called. 115e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 116e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef struct ANativeActivityCallbacks { 117e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 118e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * NativeActivity has started. See Java documentation for Activity.onStart() 119e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for more information. 120e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 121e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onStart)(ANativeActivity* activity); 122e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 123e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 124e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * NativeActivity has resumed. See Java documentation for Activity.onResume() 125e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for more information. 126e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 127e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onResume)(ANativeActivity* activity); 128e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 129e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 130e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Framework is asking NativeActivity to save its current instance state. 131e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * See Java documentation for Activity.onSaveInstanceState() for more 132e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * information. The returned pointer needs to be created with malloc(); 133e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * the framework will call free() on it for you. You also must fill in 134e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * outSize with the number of bytes in the allocation. Note that the 135e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * saved state will be persisted, so it can not contain any active 136e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * entities (pointers to memory, file descriptors, etc). 137e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 138e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void* (*onSaveInstanceState)(ANativeActivity* activity, size_t* outSize); 139e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 140e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 141e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * NativeActivity has paused. See Java documentation for Activity.onPause() 142e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for more information. 143e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 144e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onPause)(ANativeActivity* activity); 145e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 146e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 147e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * NativeActivity has stopped. See Java documentation for Activity.onStop() 148e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for more information. 149e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 150e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onStop)(ANativeActivity* activity); 151e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 152e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 153e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * NativeActivity is being destroyed. See Java documentation for Activity.onDestroy() 154e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for more information. 155e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 156e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onDestroy)(ANativeActivity* activity); 157e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 158e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 159e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Focus has changed in this NativeActivity's window. This is often used, 160e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for example, to pause a game when it loses input focus. 161e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 162e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus); 163e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 164e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 165e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The drawing window for this native activity has been created. You 166e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * can use the given native window object to start drawing. 167e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 168e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window); 169e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 170e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 171e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The drawing window for this native activity has been resized. You should 172e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * retrieve the new size from the window and ensure that your rendering in 173e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * it now matches. 174e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 175e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onNativeWindowResized)(ANativeActivity* activity, ANativeWindow* window); 176e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 177e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 178e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The drawing window for this native activity needs to be redrawn. To avoid 179e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * transient artifacts during screen changes (such resizing after rotation), 180e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * applications should not return from this function until they have finished 181e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * drawing their window in its current state. 182e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 183e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onNativeWindowRedrawNeeded)(ANativeActivity* activity, ANativeWindow* window); 184e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 185e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 186e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The drawing window for this native activity is going to be destroyed. 187e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * You MUST ensure that you do not touch the window object after returning 188e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * from this function: in the common case of drawing to the window from 189e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * another thread, that means the implementation of this callback must 190e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * properly synchronize with the other thread to stop its drawing before 191e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * returning from here. 192e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 193e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onNativeWindowDestroyed)(ANativeActivity* activity, ANativeWindow* window); 194e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 195e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 196e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The input queue for this native activity's window has been created. 197e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * You can use the given input queue to start retrieving input events. 198e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 199e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onInputQueueCreated)(ANativeActivity* activity, AInputQueue* queue); 200e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 201e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 202e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The input queue for this native activity's window is being destroyed. 203e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * You should no longer try to reference this object upon returning from this 204e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * function. 205e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 206e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue); 207e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 208e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 209e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The rectangle in the window in which content should be placed has changed. 210e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 211e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onContentRectChanged)(ANativeActivity* activity, const ARect* rect); 212e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 213e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 214e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The current device AConfiguration has changed. The new configuration can 215e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * be retrieved from assetManager. 216e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 217e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onConfigurationChanged)(ANativeActivity* activity); 218e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 219e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian /** 220e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The system is running low on memory. Use this callback to release 221e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * resources you do not need, to help the system avoid killing more 222e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * important processes. 223e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 224e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void (*onLowMemory)(ANativeActivity* activity); 225e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian} ANativeActivityCallbacks; 226e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 227e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 228e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * This is the function that must be in the native code to instantiate the 229e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * application's native activity. It is called with the activity instance (see 230e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * above); if the code is being instantiated from a previously saved instance, 231e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * the savedState will be non-NULL and point to the saved data. You must make 232e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * any copy of this data you need -- it will be released after you return from 233e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * this function. 234e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 235e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef void ANativeActivity_createFunc(ANativeActivity* activity, 236e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian void* savedState, size_t savedStateSize); 237e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 238e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 239e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * The name of the function that NativeInstance looks for when launching its 240e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * native code. This is the default function that is used, you can specify 241e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * "android.app.func_name" string meta-data in your manifest to use a different 242e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * function. 243e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 244e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianextern ANativeActivity_createFunc ANativeActivity_onCreate; 245e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 246e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 247e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Finish the given activity. Its finish() method will be called, causing it 248e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * to be stopped and destroyed. Note that this method can be called from 249e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * *any* thread; it will send a message to the main thread of the process 250e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * where the Java finish call will take place. 251e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 252e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianvoid ANativeActivity_finish(ANativeActivity* activity); 253e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 254e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 255e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Change the window format of the given activity. Calls getWindow().setFormat() 256e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * of the given activity. Note that this method can be called from 257e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * *any* thread; it will send a message to the main thread of the process 258e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * where the Java finish call will take place. 259e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 260e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianvoid ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format); 261e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 262e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 263e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Change the window flags of the given activity. Calls getWindow().setFlags() 264e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * of the given activity. Note that this method can be called from 265e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * *any* thread; it will send a message to the main thread of the process 266e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * where the Java finish call will take place. See window.h for flag constants. 267e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 268e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianvoid ANativeActivity_setWindowFlags(ANativeActivity* activity, 269e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian uint32_t addFlags, uint32_t removeFlags); 270e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 271e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 272e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager 273e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * API for documentation. 274e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 275e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianenum { 276e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001, 277e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002, 278e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian}; 279e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 280e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 281e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Show the IME while in the given activity. Calls InputMethodManager.showSoftInput() 282e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for the given activity. Note that this method can be called from 283e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * *any* thread; it will send a message to the main thread of the process 284e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * where the Java finish call will take place. 285e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 286e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianvoid ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags); 287e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 288e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 289e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager 290e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * API for documentation. 291e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 292e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianenum { 293e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001, 294e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002, 295e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian}; 296e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 297e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/** 298e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput() 299e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * for the given activity. Note that this method can be called from 300e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * *any* thread; it will send a message to the main thread of the process 301e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * where the Java finish call will take place. 302e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */ 303e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianvoid ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags); 304e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 305e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifdef __cplusplus 306e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian}; 307e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif 308e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 309e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif // ANDROID_NATIVE_ACTIVITY_H 310e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian 311