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