您的位置:首页 > 移动开发

google tv上webview页面js实现焦点跳转

2016-07-09 19:09 741 查看
我们在webview里面使用javascript处理按键遇到了焦点问题,于是google,发现了stackoverflow里面的答案,http://stackoverflow.com/questions/19716840/handle-arrow-keys-from-d-pad-on-webview-google-tv-app

于是从https://code.google.com/archive/p/googletv-android-samples/source/default/source这里下载了代码。

我把http-client的js代码拷贝到了本地的assets目录,发现焦点仍然不起作用。于是跟到了js代码,发现了如下代码

IndexPage.prototype.setUpKeyHandling = function () {
if(this.isEmbedded()) {
// We want the native app to access this
window.androidKeyHandler = new AndroidKeyHandler(this.getFocusController());
}
};

原来这里有限制,于是我修改了代码,发现可用。

IndexPage.prototype.setUpKeyHandling = function () {
//    if(this.isEmbedded()) {
// We want the native app to access this
window.androidKeyHandler = new AndroidKeyHandler(this.getFocusController());
//    }
};


具体工程代码可以从这里下载,在Android Studio测试有效。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: