APP_CMD_WINDOW_RESIZED 未被调用,但本机 window 已调整大小
APP_CMD_WINDOW_RESIZED is not called but native window is resized
我有本机应用程序,它被配置为在设备方向更改时不破坏 activity。
<activity android:name="android.app.NativeActivity"
...
android:configChanges="orientation|screenSize"
...
>
当设备方向改变时仅 触发本机生命周期命令后。
/**
* Command from main thread: the current device configuration has changed.
*/
APP_CMD_CONFIG_CHANGED
在命令处理程序中,我可以看到 window 大小已通过 ANativeWindow_getHeight
函数更改。
(我知道 ANativeWindow_getHeight
函数不是在配置更改处理程序中使用以获得 window 大小的最佳主意,我只需要检查 [= =35=] 已调整大小。)
如果调整本机 windows 的大小,我想应该触发以下本机命令?
/**
* Command from main thread: the current ANativeWindow has been resized.
* Please redraw with its new size.
*/
APP_CMD_WINDOW_RESIZED
为什么被屏蔽了?
自己找出原因,
android 本机应用程序胶水没有触发 APP_CMD_WINDOW_RESIZED
命令的代码。但只有它的定义。
之所以这样,是因为app glue code没有注册原生回调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);
}
最后,它没有注册的原因是 android 描述的错误 here
原生回调的文档是here
我有本机应用程序,它被配置为在设备方向更改时不破坏 activity。
<activity android:name="android.app.NativeActivity"
...
android:configChanges="orientation|screenSize"
...
>
当设备方向改变时仅 触发本机生命周期命令后。
/**
* Command from main thread: the current device configuration has changed.
*/
APP_CMD_CONFIG_CHANGED
在命令处理程序中,我可以看到 window 大小已通过 ANativeWindow_getHeight
函数更改。
(我知道 ANativeWindow_getHeight
函数不是在配置更改处理程序中使用以获得 window 大小的最佳主意,我只需要检查 [= =35=] 已调整大小。)
如果调整本机 windows 的大小,我想应该触发以下本机命令?
/**
* Command from main thread: the current ANativeWindow has been resized.
* Please redraw with its new size.
*/
APP_CMD_WINDOW_RESIZED
为什么被屏蔽了?
自己找出原因,
android 本机应用程序胶水没有触发 APP_CMD_WINDOW_RESIZED
命令的代码。但只有它的定义。
之所以这样,是因为app glue code没有注册原生回调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);
}
最后,它没有注册的原因是 android 描述的错误 here
原生回调的文档是here