Adobe AIR后退按钮事件不适用于Android API 28+

编程入门 行业动态 更新时间:2024-10-23 19:26:17
本文介绍了Adobe AIR后退按钮事件不适用于Android API 28+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

key_down事件未触发,我们无法阻止该应用程序关闭。当我们仅针对Android API 28+时,这便在Adobe AIR游戏中发生(如果该构建针对API 27或更低版​​本,则一切正常)

The key_down event is not being fired and we are not able to prevent the app to be closed. It's happening on Adobe AIR games when we target to Android API 28+ only (everything works fine if the build was targeted to API 27 or lower)

NativeApplication.nativeApplication.addEventListener( KeyboardEvent.KEY_DOWN, keyDownHandler ); function keyDownHandler( event:KeyboardEvent ):void { trace( event.keyCode ); if (event.keyCode == Keyboard.BACK) { event.preventDefault(); } }

我做了一些研究,通过Adobe AIR进行了一些研究.jar文件,一切看起来都不错。实际上,我通过其AndroidActivityWrapper进行了一些更改以处理dispatchKeyEvent(),收到了事件,并返回 true以防止应用程序关闭,但仍无法正常工作,它会忽略该事件。

I did some research, I went through some Adobe AIR .jar files and everything looks good. In fact I did some changes to handle the dispatchKeyEvent() through their AndroidActivityWrapper, I received the event and I return 'true' to prevent the app to be closed, but still not working, it's ignoring the event.

我需要一些有关Android API 28中更改内容的线索,为什么同一个Adobe AIR sdk仅在使用此API时会失败。我读到Harman正在修复,但没有官方信息。

I need some clues about what was changed in Android API 28, why the same Adobe AIR sdk fails only with this API. I read that Harman is working on a fix but there are no official information about that.

我提供了stacktrace的一部分,您可以在其中看到来自本地android的dispatchKeyEvent调用组件:

I provide part of the stacktrace where you can see the dispatchKeyEvent call coming from native android components:

at com.app.mobile.appMobile.onKeyDown(appMobile.java:834) at com.core.ane.Context.onKeyEvent(Context.java:669) at com.adobe.air.AndroidActivityWrapper.callInputEventListeners(AndroidActivityWrapper.java:1921) at com.adobe.air.AndroidActivityWrapper.dispatchKeyEvent(AndroidActivityWrapper.java:1488) at java.lang.reflect.Method.invoke(Native Method) at air.app.mobile.test.AppEntry.InvokeMethod(AppEntry.java:365) at air.app.mobile.test.AppEntry.dispatchKeyEvent(AppEntry.java:496) at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:563) at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:6038) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5893)

推荐答案

最后我发现了问题,这与我将游戏定位到Android API 28时没有将焦点分配给AIRWindowSurfaceView有关。

Finally I found the problem, it's related to the focus not being assigned to AIRWindowSurfaceView when I target the game to Android API 28.

这是在初始化ANE以便恢复焦点:

This is the code I have to run when the ANE is initialized in order to restore the focus:

AndroidActivityWrapper aaw = AndroidActivityWrapper.GetAndroidActivityWrapper(); aaw.getView().requestFocus(); aaw.getView().onWindowFocusChanged(true);

更多推荐

Adobe AIR后退按钮事件不适用于Android API 28+

本文发布于:2023-11-23 14:09:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621719.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   不适用于   事件   AIR   Adobe

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!