169969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn/* 269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * Copyright (C) 2010 The Android Open Source Project 369969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * 469969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 569969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * you may not use this file except in compliance with the License. 669969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * You may obtain a copy of the License at 769969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * 869969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 969969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * 1069969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * Unless required by applicable law or agreed to in writing, software 1169969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 1269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1369969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * See the License for the specific language governing permissions and 1469969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn * limitations under the License. 1569969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn */ 1669969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 1769969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 1869969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#ifndef ANDROID_NATIVE_ACTIVITY_H 1969969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#define ANDROID_NATIVE_ACTIVITY_H 2069969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 2169969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#include <stdint.h> 2269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#include <sys/types.h> 2369969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 2469969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#include <jni.h> 2569969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 266cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate#include <android/asset_manager.h> 27a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn#include <android/input.h> 2854a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn#include <android/native_window.h> 29a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn 3069969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#ifdef __cplusplus 3169969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackbornextern "C" { 3269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#endif 3369969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 342e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornstruct ANativeActivityCallbacks; 3569969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 3674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn/** 3774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * This structure defines the native side of an android.app.NativeActivity. 3874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * It is created by the framework, and handed to the application's native 3974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * code as it is being launched. 4074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 412e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborntypedef struct ANativeActivity { 4274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 4374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * Pointer to the callback function table of the native application. 4474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * You can set the functions here to your own callbacks. The callbacks 4574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * pointer itself here should not be changed; it is allocated and managed 4674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for you by the framework. 4774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 482e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn struct ANativeActivityCallbacks* callbacks; 4969969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 5074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 512e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn * The global handle on the process's Java VM. 522e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn */ 532e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn JavaVM* vm; 542e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn 552e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn /** 562e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn * JNI context for the main thread of the app. Note that this field 572e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn * can ONLY be used from the main thread of the process; that is, the 582e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn * thread that calls into the ANativeActivityCallbacks. 5974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 6069969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn JNIEnv* env; 612e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn 6274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 6374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * The NativeActivity Java class. 6474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 6569969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn jobject clazz; 6669969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 6774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 68682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn * Path to this application's internal data directory. 69682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn */ 70682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn const char* internalDataPath; 71682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn 72682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn /** 73682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn * Path to this application's external (removable/mountable) data directory. 74682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn */ 75682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn const char* externalDataPath; 76682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn 77682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn /** 78682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn * The platform's SDK version code. 79682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn */ 80682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn int32_t sdkVersion; 81682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn 82682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn /** 8374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * This is the native instance of the application. It is not used by 8474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * the framework, but can be set by the application to its own instance 8574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * state. 8674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 8769969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn void* instance; 886cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate 896cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate /** 906cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * Pointer to the Asset Manager instance for the application. The application 916cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate * uses this to access binary assets bundled inside its own .apk file. 926cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate */ 936cce32b6adbb3a9725fc730ba0e0068a74657e60Christopher Tate AAssetManager* assetManager; 94805fd7ee0e5dc2939e85c84f78d9890a51982bc0Dianne Hackborn 95805fd7ee0e5dc2939e85c84f78d9890a51982bc0Dianne Hackborn /** 96805fd7ee0e5dc2939e85c84f78d9890a51982bc0Dianne Hackborn * Available starting with Honeycomb: path to the directory containing 97805fd7ee0e5dc2939e85c84f78d9890a51982bc0Dianne Hackborn * the application's OBB files (if any). If the app doesn't have any 98805fd7ee0e5dc2939e85c84f78d9890a51982bc0Dianne Hackborn * OBB files, this directory may not exist. 99805fd7ee0e5dc2939e85c84f78d9890a51982bc0Dianne Hackborn */ 100805fd7ee0e5dc2939e85c84f78d9890a51982bc0Dianne Hackborn const char* obbPath; 1012e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn} ANativeActivity; 10269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 10374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn/** 10474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * These are the callbacks the framework makes into a native application. 10574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * All of these callbacks happen on the main thread of the application. 10674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * By default, all callbacks are NULL; set to a pointer to your own function 10774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * to have it called. 10874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1092e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborntypedef struct ANativeActivityCallbacks { 11074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 11174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity has started. See Java documentation for Activity.onStart() 11274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 11374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1142e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onStart)(ANativeActivity* activity); 11574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 11674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 11774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity has resumed. See Java documentation for Activity.onResume() 11874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 11974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1202e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onResume)(ANativeActivity* activity); 12174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 12274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 12374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * Framework is asking NativeActivity to save its current instance state. 12474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * See Java documentation for Activity.onSaveInstanceState() for more 12574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * information. The returned pointer needs to be created with malloc(); 12674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * the framework will call free() on it for you. You also must fill in 12774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * outSize with the number of bytes in the allocation. Note that the 12874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * saved state will be persisted, so it can not contain any active 12974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * entities (pointers to memory, file descriptors, etc). 13074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1312e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void* (*onSaveInstanceState)(ANativeActivity* activity, size_t* outSize); 13274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 13374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 13474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity has paused. See Java documentation for Activity.onPause() 13574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 13674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1372e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onPause)(ANativeActivity* activity); 13874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 13974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 14074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity has stopped. See Java documentation for Activity.onStop() 14174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 14274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1432e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onStop)(ANativeActivity* activity); 14474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 14574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 14674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity is being destroyed. See Java documentation for Activity.onDestroy() 14774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 14874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1492e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onDestroy)(ANativeActivity* activity); 15069969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 15174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 15274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * Focus has changed in this NativeActivity's window. This is often used, 15374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for example, to pause a game when it loses input focus. 15474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1552e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus); 15674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 15774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 15854a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * The drawing window for this native activity has been created. You 15954a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * can use the given native window object to start drawing. 16074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 16154a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window); 16274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 16374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 164d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * The drawing window for this native activity has been resized. You should 165d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * retrieve the new size from the window and ensure that your rendering in 166d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * it now matches. 167d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 168d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn void (*onNativeWindowResized)(ANativeActivity* activity, ANativeWindow* window); 169d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 170d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn /** 171d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * The drawing window for this native activity needs to be redrawn. To avoid 172d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * transient artifacts during screen changes (such resizing after rotation), 173d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * applications should not return from this function until they have finished 174d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * drawing their window in its current state. 175d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 176d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn void (*onNativeWindowRedrawNeeded)(ANativeActivity* activity, ANativeWindow* window); 177d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 178d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn /** 17954a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * The drawing window for this native activity is going to be destroyed. 18054a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * You MUST ensure that you do not touch the window object after returning 18154a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * from this function: in the common case of drawing to the window from 18274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * another thread, that means the implementation of this callback must 18374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * properly synchronize with the other thread to stop its drawing before 18474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * returning from here. 18574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 18654a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn void (*onNativeWindowDestroyed)(ANativeActivity* activity, ANativeWindow* window); 187a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn 188a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn /** 189a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * The input queue for this native activity's window has been created. 190a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * You can use the given input queue to start retrieving input events. 191a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */ 1922e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onInputQueueCreated)(ANativeActivity* activity, AInputQueue* queue); 193a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn 194a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn /** 195a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * The input queue for this native activity's window is being destroyed. 196a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * You should no longer try to reference this object upon returning from this 197a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * function. 198a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */ 1992e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue); 20074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 20174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 202d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * The rectangle in the window in which content should be placed has changed. 203d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 204d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn void (*onContentRectChanged)(ANativeActivity* activity, const ARect* rect); 205d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 206d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn /** 20708d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * The current device AConfiguration has changed. The new configuration can 20808d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * be retrieved from assetManager. 20908d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn */ 21008d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn void (*onConfigurationChanged)(ANativeActivity* activity); 21108d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn 21208d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn /** 21374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * The system is running low on memory. Use this callback to release 21474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * resources you do not need, to help the system avoid killing more 21574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * important processes. 21674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 2172e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onLowMemory)(ANativeActivity* activity); 2182e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn} ANativeActivityCallbacks; 21969969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 22074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn/** 22174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * This is the function that must be in the native code to instantiate the 22274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * application's native activity. It is called with the activity instance (see 22374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * above); if the code is being instantiated from a previously saved instance, 22408d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * the savedState will be non-NULL and point to the saved data. You must make 22508d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * any copy of this data you need -- it will be released after you return from 22608d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * this function. 22774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 2282e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborntypedef void ANativeActivity_createFunc(ANativeActivity* activity, 22969969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn void* savedState, size_t savedStateSize); 23069969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 23174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn/** 23274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * The name of the function that NativeInstance looks for when launching its 233e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * native code. This is the default function that is used, you can specify 234e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * "android.app.func_name" string meta-data in your manifest to use a different 235e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * function. 23674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 2372e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornextern ANativeActivity_createFunc ANativeActivity_onCreate; 23869969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 239db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackborn/** 240db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackborn * Finish the given activity. Its finish() method will be called, causing it 241e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * to be stopped and destroyed. Note that this method can be called from 242e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 243e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. 244db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackborn */ 245db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackbornvoid ANativeActivity_finish(ANativeActivity* activity); 246db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackborn 247e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn/** 248e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * Change the window format of the given activity. Calls getWindow().setFormat() 249e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * of the given activity. Note that this method can be called from 250e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 251e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. 252e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn */ 253289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackbornvoid ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format); 254289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackborn 255e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn/** 256e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * Change the window flags of the given activity. Calls getWindow().setFlags() 257e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * of the given activity. Note that this method can be called from 258e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 259e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. See window.h for flag constants. 260e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn */ 261289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackbornvoid ANativeActivity_setWindowFlags(ANativeActivity* activity, 262289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackborn uint32_t addFlags, uint32_t removeFlags); 263289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackborn 264d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn/** 265d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager 266d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * API for documentation. 267d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 268d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornenum { 269d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001, 270d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002, 271d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn}; 272d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 273e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn/** 274e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * Show the IME while in the given activity. Calls InputMethodManager.showSoftInput() 275e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * for the given activity. Note that this method can be called from 276e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 277e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. 278e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn */ 279d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornvoid ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags); 280d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 281d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn/** 282d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager 283d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * API for documentation. 284d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 285d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornenum { 286d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001, 287d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002, 288d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn}; 289d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 290e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn/** 291e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput() 292e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * for the given activity. Note that this method can be called from 293e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 294e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. 295e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn */ 296d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornvoid ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags); 297d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 29869969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#ifdef __cplusplus 29969969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn}; 30069969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#endif 30169969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 30269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#endif // ANDROID_NATIVE_ACTIVITY_H 30369969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 304