Amazon Fire Stick上的Webview不响应控制器 [英] Webview on Amazon Fire Stick not responding to controller

查看:118
本文介绍了Amazon Fire Stick上的Webview不响应控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Cocos2d-x中有一个Android应用,该应用使用WebView显示前端菜单。目前,它只是一个模型,并且只有一个指向网站的URL,这使其易于测试。

I've got an Android app in Cocos2d-x that uses a WebView to display the front end menu. Currently it's just a mock-up, and just has a URL to a website, which makes it easy to test.

如果我在Amazon中加载界面的URL Amazon Fire TV棒上的Web App Tester可以完美运行,您可以使用控制器愉快地浏览界面。

If I load the URL of the interface in the Amazon Web App Tester on an Amazon Fire TV stick it works perfectly, and you can navigate the interface happily with the controller.

但是,当我在棒上加载应用程序时,在WebView组件中显示相同的URL,则控制器无效,并且不导航(甚至突出显示)界面。

However, when I load the app on the stick, which shows the same URL in a WebView component then the controller has no effect and doesn't navigate (or even highlight) the interface.

如何获取WebView在测试器应用中的行为类似于网络视图,并响应控制器?

How can I get the WebView to behave like the web view in the tester app, and respond to the controller?

推荐答案

最后,问题是我需要调用超类函数,而不是返回false来表示我未处理输入。未设置cocos2d-x GameControllerActivity类来解决此问题,因此我不得不修改GameControllerActivity.java并添加一个新的静态成员/函数,以指示何时我希望我的应用具有控制器输入或是否可以输入

In the end the problem was that I needed to call the superclass functions, not return false to indicate I hadn't processed the input. The cocos2d-x GameControllerActivity class isn't set up to cope with this, so I had to modify GameControllerActivity.java and add a new static member/functions to indicate when I wanted my app to have the controller input or if it was OK to pass it on to the WebView to process.

其他功能:

private static boolean smGrabJoypadInput = false;

public static void grabJoypad() {
    smGrabJoypadInput = true;
}

public static void releaseJoypad() {
    smGrabJoypadInput = false;
}

修改后的功能:

@Override
public boolean dispatchKeyEvent(KeyEvent event) {

if (!smGrabJoypadInput)
   return super.dispatchKeyEvent(event);
...

@Override
public boolean dispatchGenericMotionEvent(MotionEvent event) {

    if (!smGrabJoypadInput)
        return super.dispatchGenericMotionEvent(event);

然后我在需要时通过JNI调用了这些函数。

Then I called these functions via JNI when I needed them.

这篇关于Amazon Fire Stick上的Webview不响应控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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