|API for accessing a native window. |
|typedef struct ANativeActivity||ANativeActivity|
|typedef struct ANativeActivityCallbacks||ANativeActivityCallbacks|
|typedef void||ANativeActivity_createFunc(ANativeActivity *activity, void *savedState, size_t savedStateSize)|
|typedef struct ANativeWindow||ANativeWindow|
|typedef struct ANativeWindow_Buffer||ANativeWindow_Buffer|
|typedef struct ARect||ARect|
This structure defines the native side of an android.app.NativeActivity. It is created by the framework, and handed to the application's native code as it is being launched.
|typedef void ANativeActivity_createFunc(ANativeActivity *activity, void *savedState, size_t savedStateSize)|
This is the function that must be in the native code to instantiate the application's native activity. It is called with the activity instance (see above); if the code is being instantiated from a previously saved instance, the savedState will be non-NULL and point to the saved data. You must make any copy of this data you need – it will be released after you return from this function.
These are the callbacks the framework makes into a native application. All of these callbacks happen on the main thread of the application. By default, all callbacks are NULL; set to a pointer to your own function to have it called.
Opaque type that provides access to a native window.
A pointer can be obtained using ANativeWindow_fromSurface().
Struct that represents a windows buffer.
A pointer can be obtained using ANativeWindow_lock().
Enumeration Type Documentation
Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager API for documentation.
Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager API for documentation.
The soft input window should only be hidden if it was not explicitly shown by the user.
The soft input window should normally be hidden, unless it was originally shown with ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED.
Legacy window pixel format names, kept for backwards compatibility. New code and APIs should use AHARDWAREBUFFER_FORMAT_*.
Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits.
Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits.
Red: 5 bits, Green: 6 bits, Blue: 5 bits.
Window flags, as per the Java API at android.view.WindowManager.LayoutParams.
As long as this window is visible to the user, allow the lock screen to activate while the screen is on. This can be used independently, or in combination with AWINDOW_FLAG_KEEP_SCREEN_ON and/or AWINDOW_FLAG_SHOW_WHEN_LOCKED
Everything behind this window will be dimmed.
Blur everything behind this window.
This window won't ever get key input focus, so the user can not send key or other button events to it. Those will instead go to whatever focusable window is behind it. This flag will also enable AWINDOW_FLAG_NOT_TOUCH_MODAL whether or not that is explicitly set.
Setting this flag also implies that the window will not need to interact with a soft input method, so it will be Z-ordered and positioned independently of any active input method (typically this means it gets Z-ordered on top of the input method, so it can use the full screen for its content and cover the input method if needed. You can use AWINDOW_FLAG_ALT_FOCUSABLE_IM to modify this behavior.
this window can never receive touch events.
Even when this window is focusable (its AWINDOW_FLAG_NOT_FOCUSABLE is not set), allow any pointer events outside of the window to be sent to the windows behind it. Otherwise it will consume all pointer events itself, regardless of whether they are inside of the window.
When set, if the device is asleep when the touch screen is pressed, you will receive this first touch event. Usually the first touch event is consumed by the system since the user can not see what they are pressing on.
As long as this window is visible to the user, keep the device's screen turned on and bright.
Place the window within the entire screen, ignoring decorations around the border (such as the status bar). The window must correctly position its contents to take the screen decoration into account.
allow window to extend outside of the screen.
Hide all screen decorations (such as the status bar) while this window is displayed. This allows the window to use the entire display space for itself – the status bar will be hidden when an app window with this flag set is on the top layer. A fullscreen window will ignore a value of AWINDOW_SOFT_INPUT_ADJUST_RESIZE; the window will stay fullscreen and will not resize.
Override AWINDOW_FLAG_FULLSCREEN and force the screen decorations (such as the status bar) to be shown.
Turn on dithering when compositing this window to the screen.
Treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.
A special mode where the layout parameters are used to perform scaling of the surface when it is composited to the screen.
Intended for windows that will often be used when the user is holding the screen against their face, it will aggressively filter the event stream to prevent unintended presses in this situation that may not be desired for a particular window, when such an event stream is detected, the application will receive a AMOTION_EVENT_ACTION_CANCEL to indicate this so applications can handle this accordingly by taking no action on the event until the finger is released.
A special option only for use in combination with AWINDOW_FLAG_LAYOUT_IN_SCREEN. When requesting layout in the screen your window may appear on top of or behind screen decorations such as the status bar. By also including this flag, the window manager will report the inset rectangle needed to ensure your content is not covered by screen decorations.
Invert the state of AWINDOW_FLAG_NOT_FOCUSABLE with respect to how this window interacts with the current method. That is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the window will behave as if it needs to interact with the input method and thus be placed behind/away from it; if AWINDOW_FLAG_NOT_FOCUSABLE is not set and this flag is set, then the window will behave as if it doesn't need to interact with the input method and can be placed to use more space and cover the input method.
If you have set AWINDOW_FLAG_NOT_TOUCH_MODAL, you can set this flag to receive a single special MotionEvent with the action AMOTION_EVENT_ACTION_OUTSIDE for touches that occur outside of your window. Note that you will not receive the full down/move/up gesture, only the location of the first down as an AMOTION_EVENT_ACTION_OUTSIDE.
Special flag to let windows be shown when the screen is locked. This will let application windows take precedence over key guard or any other lock screens. Can be used with AWINDOW_FLAG_KEEP_SCREEN_ON to turn screen on and display windows directly before showing the key guard window. Can be used with AWINDOW_FLAG_DISMISS_KEYGUARD to automatically fully dismisss non-secure keyguards. This flag only applies to the top-most full-screen window.
Ask that the system wallpaper be shown behind your window. The window surface must be translucent to be able to actually see the wallpaper behind it; this flag just ensures that the wallpaper surface will be there if this window actually has translucent regions.
When set as a window is being added or made visible, once the window has been shown then the system will poke the power manager's user activity (as if the user had woken up the device) to turn the screen on.
When set the window will cause the keyguard to be dismissed, only if it is not a secure lock keyguard. Because such a keyguard is not needed for security, it will never re-appear if the user navigates to another window (in contrast to AWINDOW_FLAG_SHOW_WHEN_LOCKED, which will only temporarily hide both secure and non-secure keyguards but ensure they reappear when the user moves to another UI that doesn't hide them). If the keyguard is currently active and is secure (requires an unlock pattern) than the user will still need to confirm it before seeing this window, unless AWINDOW_FLAG_SHOW_WHEN_LOCKED has also been set.
Transforms that can be applied to buffers as they are displayed to a window.
Supported transforms are any combination of horizontal mirror, vertical mirror, and clockwise 90 degree rotation, in that order. Rotations of 180 and 270 degrees are made up of those basic transforms.
|void ANativeActivity_finish||(||ANativeActivity *||activity||)|
Finish the given activity. Its finish() method will be called, causing it to be stopped and destroyed. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.
|void ANativeActivity_hideSoftInput||(||ANativeActivity *||activity,|
Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput() for the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.
|void ANativeActivity_setWindowFlags||(||ANativeActivity *||activity,|
Change the window flags of the given activity. Calls getWindow().setFlags() of the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place. See window.h for flag constants.
|void ANativeActivity_setWindowFormat||(||ANativeActivity *||activity,|
Change the window format of the given activity. Calls getWindow().setFormat() of the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.
|void ANativeActivity_showSoftInput||(||ANativeActivity *||activity,|
Show the IME while in the given activity. Calls InputMethodManager.showSoftInput() for the given activity. Note that this method can be called from any thread; it will send a message to the main thread of the process where the Java finish call will take place.
|void ANativeWindow_acquire||(||ANativeWindow *||window||)|
Acquire a reference on the given ANativeWindow object. This prevents the object from being deleted until the reference is removed.
|ANativeWindow* ANativeWindow_fromSurface||(||JNIEnv *||env,|
Return the ANativeWindow associated with a Java Surface object, for interacting with it through native code. This acquires a reference on the ANativeWindow that is returned; be sure to use ANativeWindow_release() when done with it so that it doesn't leak.
|ANativeWindow* ANativeWindow_fromSurfaceTexture||(||JNIEnv *||env,|
Return the ANativeWindow associated with a Java SurfaceTexture object, for interacting with it through native code. This acquires a reference on the ANativeWindow that is returned; be sure to use ANativeWindow_release() when done with it so that it doesn't leak.
|int32_t ANativeWindow_getFormat||(||ANativeWindow *||window||)|
Return the current pixel format (AHARDWAREBUFFER_FORMAT_*) of the window surface.
- a negative value on error.
|int32_t ANativeWindow_getHeight||(||ANativeWindow *||window||)|
Return the current height in pixels of the window surface.
- a negative value on error.
|int32_t ANativeWindow_getWidth||(||ANativeWindow *||window||)|
Return the current width in pixels of the window surface.
- negative value on error.
|int32_t ANativeWindow_lock||(||ANativeWindow *||window,|
Lock the window's next drawing surface for writing. inOutDirtyBounds is used as an in/out parameter, upon entering the function, it contains the dirty region, that is, the region the caller intends to redraw. When the function returns, inOutDirtyBounds is updated with the actual area the caller needs to redraw – this region is often extended by ANativeWindow_lock.
- 0 for success, or a negative value on error.
|void ANativeWindow_release||(||ANativeWindow *||window||)|
Remove a reference that was previously acquired with ANativeWindow_acquire().
|int32_t ANativeWindow_setBuffersGeometry||(||ANativeWindow *||window,|
Change the format and size of the window buffers.
The width and height control the number of pixels in the buffers, not the dimensions of the window on screen. If these are different than the window's physical size, then its buffer will be scaled to match that size when compositing it to the screen. The width and height must be either both zero or both non-zero.
For all of these parameters, if 0 is supplied then the window's base value will come back in force.
width width of the buffers in pixels. height height of the buffers in pixels. format one of AHARDWAREBUFFER_FORMAT_* constants.
- 0 for success, or a negative value on error.
|int32_t ANativeWindow_setBuffersTransform||(||ANativeWindow *||window,|
Set a transform that will be applied to future buffers posted to the window.
transform combination of ANativeWindowTransform flags
- 0 for success, or -EINVAL if
|jobject ANativeWindow_toSurface||(||JNIEnv *||env,|
Return a Java Surface object derived from the ANativeWindow, for interacting with it through Java code. The returned Java object acquires a reference on the ANativeWindow; maintains it through general Java object's life cycle; and will automatically release the reference when the Java object gets garbage collected.
|int32_t ANativeWindow_unlockAndPost||(||ANativeWindow *||window||)|
Unlock the window's drawing surface after previously locking it, posting the new buffer to the display.
- 0 for success, or a negative value on error.
The name of the function that NativeInstance looks for when launching its native code. This is the default function that is used, you can specify "android.app.func_name" string meta-data in your manifest to use a different function.