Adobe AIR后退按钮事件不适用于Android API 28+ [英] Adobe AIR back button event not working with Android API 28+

查看:114
本文介绍了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.com.app.mobile.test.AppEntry.InvokeMethod(AppEntry.java:365)
 at air.com.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+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆