I've native app, which is configured to not destroy activity on device orientation change.
<activity android:name="android.app.NativeActivity"
...
android:configChanges="orientation|screenSize"
...
>
When the devices orientation changes only following Native life-cycle command is triggered.
/**
* Command from main thread: the current device configuration has changed.
*/
APP_CMD_CONFIG_CHANGED
In the command handler I can see that the window size has been changed with ANativeWindow_getHeight
function.
(I know that ANativeWindow_getHeight
function is not the best idea to use in config change handler to get the window size, I just only need to check if the window has been resized.)
If the native windows is resized I suppose following native command should be triggered ?
/**
* Command from main thread: the current ANativeWindow has been resized.
* Please redraw with its new size.
*/
APP_CMD_WINDOW_RESIZED
Why it has been blocked ?
Figured out the reason myself,
The android native app glue does not have a code for firing APP_CMD_WINDOW_RESIZED
command. But only has the definition for it.
The reason for that, is because app glue code does not register the native callback onNativeWindowResized
void ANativeActivity_onCreate(ANativeActivity* activity,
void* savedState, size_t savedStateSize) {
LOGV("Creating: %p\n", activity);
activity->callbacks->onDestroy = onDestroy;
activity->callbacks->onStart = onStart;
activity->callbacks->onResume = onResume;
activity->callbacks->onSaveInstanceState = onSaveInstanceState;
activity->callbacks->onPause = onPause;
activity->callbacks->onStop = onStop;
activity->callbacks->onConfigurationChanged = onConfigurationChanged;
activity->callbacks->onLowMemory = onLowMemory;
activity->callbacks->onWindowFocusChanged = onWindowFocusChanged;
activity->callbacks->onNativeWindowCreated = onNativeWindowCreated;
activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed;
activity->callbacks->onInputQueueCreated = onInputQueueCreated;
activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed;
activity->instance = android_app_create(activity, savedState, savedStateSize);
}
And finally the reason why it does not register for it is an android bug described here
The documentation of native callbacks is here