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; 942e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn} ANativeActivity; 9569969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 9674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn/** 9774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * These are the callbacks the framework makes into a native application. 9874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * All of these callbacks happen on the main thread of the application. 9974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * By default, all callbacks are NULL; set to a pointer to your own function 10074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * to have it called. 10174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1022e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborntypedef struct ANativeActivityCallbacks { 10374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 10474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity has started. See Java documentation for Activity.onStart() 10574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 10674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1072e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onStart)(ANativeActivity* activity); 10874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 10974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 11074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity has resumed. See Java documentation for Activity.onResume() 11174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 11274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1132e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onResume)(ANativeActivity* activity); 11474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 11574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 11674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * Framework is asking NativeActivity to save its current instance state. 11774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * See Java documentation for Activity.onSaveInstanceState() for more 11874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * information. The returned pointer needs to be created with malloc(); 11974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * the framework will call free() on it for you. You also must fill in 12074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * outSize with the number of bytes in the allocation. Note that the 12174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * saved state will be persisted, so it can not contain any active 12274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * entities (pointers to memory, file descriptors, etc). 12374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1242e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void* (*onSaveInstanceState)(ANativeActivity* activity, size_t* outSize); 12574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 12674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 12774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity has paused. See Java documentation for Activity.onPause() 12874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 12974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1302e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onPause)(ANativeActivity* activity); 13174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 13274323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 13374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity has stopped. See Java documentation for Activity.onStop() 13474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 13574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1362e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onStop)(ANativeActivity* activity); 13774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 13874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 13974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * NativeActivity is being destroyed. See Java documentation for Activity.onDestroy() 14074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for more information. 14174323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1422e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onDestroy)(ANativeActivity* activity); 14369969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 14474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 14574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * Focus has changed in this NativeActivity's window. This is often used, 14674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * for example, to pause a game when it loses input focus. 14774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 1482e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus); 14974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 15074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 15154a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * The drawing window for this native activity has been created. You 15254a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * can use the given native window object to start drawing. 15374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 15454a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window); 15574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 15674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 157d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * The drawing window for this native activity has been resized. You should 158d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * retrieve the new size from the window and ensure that your rendering in 159d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * it now matches. 160d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 161d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn void (*onNativeWindowResized)(ANativeActivity* activity, ANativeWindow* window); 162d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 163d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn /** 164d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * The drawing window for this native activity needs to be redrawn. To avoid 165d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * transient artifacts during screen changes (such resizing after rotation), 166d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * applications should not return from this function until they have finished 167d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * drawing their window in its current state. 168d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 169d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn void (*onNativeWindowRedrawNeeded)(ANativeActivity* activity, ANativeWindow* window); 170d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 171d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn /** 17254a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * The drawing window for this native activity is going to be destroyed. 17354a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * You MUST ensure that you do not touch the window object after returning 17454a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn * from this function: in the common case of drawing to the window from 17574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * another thread, that means the implementation of this callback must 17674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * properly synchronize with the other thread to stop its drawing before 17774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * returning from here. 17874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 17954a181b1a2b1517a9479b21fbf7705a688232fafDianne Hackborn void (*onNativeWindowDestroyed)(ANativeActivity* activity, ANativeWindow* window); 180a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn 181a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn /** 182a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * The input queue for this native activity's window has been created. 183a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * You can use the given input queue to start retrieving input events. 184a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */ 1852e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onInputQueueCreated)(ANativeActivity* activity, AInputQueue* queue); 186a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn 187a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn /** 188a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * The input queue for this native activity's window is being destroyed. 189a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * You should no longer try to reference this object upon returning from this 190a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * function. 191a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */ 1922e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue); 19374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn 19474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn /** 195d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * The rectangle in the window in which content should be placed has changed. 196d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 197d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn void (*onContentRectChanged)(ANativeActivity* activity, const ARect* rect); 198d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 199d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn /** 20008d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * The current device AConfiguration has changed. The new configuration can 20108d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * be retrieved from assetManager. 20208d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn */ 20308d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn void (*onConfigurationChanged)(ANativeActivity* activity); 20408d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn 20508d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn /** 20674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * The system is running low on memory. Use this callback to release 20774323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * resources you do not need, to help the system avoid killing more 20874323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * important processes. 20974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 2102e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn void (*onLowMemory)(ANativeActivity* activity); 2112e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn} ANativeActivityCallbacks; 21269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 21374323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn/** 21474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * This is the function that must be in the native code to instantiate the 21574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * application's native activity. It is called with the activity instance (see 21674323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * above); if the code is being instantiated from a previously saved instance, 21708d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * the savedState will be non-NULL and point to the saved data. You must make 21808d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * any copy of this data you need -- it will be released after you return from 21908d5b8fad8d46ccb64db2fdcb4d66972ec87bf48Dianne Hackborn * this function. 22074323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 2212e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborntypedef void ANativeActivity_createFunc(ANativeActivity* activity, 22269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn void* savedState, size_t savedStateSize); 22369969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 22474323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn/** 22574323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn * The name of the function that NativeInstance looks for when launching its 226e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * native code. This is the default function that is used, you can specify 227e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * "android.app.func_name" string meta-data in your manifest to use a different 228e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * function. 22974323fd1ab8eb11beea286d5c213c63e4b803141Dianne Hackborn */ 2302e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornextern ANativeActivity_createFunc ANativeActivity_onCreate; 23169969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 232db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackborn/** 233db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackborn * Finish the given activity. Its finish() method will be called, causing it 234e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * to be stopped and destroyed. Note that this method can be called from 235e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 236e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. 237db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackborn */ 238db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackbornvoid ANativeActivity_finish(ANativeActivity* activity); 239db28a94d499f995b467b07cee5c9b9119f538b1cDianne Hackborn 240e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn/** 241e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * Change the window format of the given activity. Calls getWindow().setFormat() 242e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * of the given activity. Note that this method can be called from 243e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 244e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. 245e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn */ 246289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackbornvoid ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format); 247289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackborn 248e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn/** 249e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * Change the window flags of the given activity. Calls getWindow().setFlags() 250e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * of the given activity. Note that this method can be called from 251e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 252e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. See window.h for flag constants. 253e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn */ 254289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackbornvoid ANativeActivity_setWindowFlags(ANativeActivity* activity, 255289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackborn uint32_t addFlags, uint32_t removeFlags); 256289b9b62372ef52a06113b83dfb870e2c2fb325aDianne Hackborn 257d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn/** 258d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager 259d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * API for documentation. 260d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 261d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornenum { 262d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001, 263d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002, 264d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn}; 265d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 266e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn/** 267e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * Show the IME while in the given activity. Calls InputMethodManager.showSoftInput() 268e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * for the given activity. Note that this method can be called from 269e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 270e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. 271e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn */ 272d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornvoid ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags); 273d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 274d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn/** 275d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager 276d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn * API for documentation. 277d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn */ 278d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornenum { 279d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001, 280d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002, 281d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn}; 282d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 283e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn/** 284e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput() 285e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * for the given activity. Note that this method can be called from 286e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * *any* thread; it will send a message to the main thread of the process 287e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn * where the Java finish call will take place. 288e21d91c694e828e6285cc50e79b2a6be6e8c692bDianne Hackborn */ 289d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornvoid ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags); 290d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn 29169969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#ifdef __cplusplus 29269969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn}; 29369969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#endif 29469969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 29569969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn#endif // ANDROID_NATIVE_ACTIVITY_H 29669969e48f2bca9339662dddfacff0bbf6374ed7fDianne Hackborn 297