Javascript的接口不工作与Android 4.2 [英] Javascript interface not working with android 4.2

查看:75
本文介绍了Javascript的接口不工作与Android 4.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临的Andr​​oid操作系统果冻豆4.2的一个严重的错误,在这里我的计划,我用JavaScript来让网页的高度,这是完全从Android 2.2的工作到4.1,但是当我试图用同样的code在安卓4.2这样的JavaScript接口不能正常工作。

I am facing a serious bug of android OS Jelly Bean 4.2, here in my program I am using JavaScript to get the height of webpage and it is perfectly working from android 2.2 to 4.1 but when I tried to use the same code in android 4.2 so the JavaScript interface not working.

我该如何解决这个问题?

How can I fix this issue?

推荐答案

从Android 4.2的文档:

From the Android 4.2 documentation:

注意:如果你已经设置你的targetSdkVersion为17或更高,则必须添加@JavascriptInterface标注任何你想用你的网页code(该方法也必须是公共的)方法。如果你不提供注释,则该方法将在Android 4.2或跑步时,不是被你的网页中较高的。

Caution: If you've set your targetSdkVersion to 17 or higher, you must add the @JavascriptInterface annotation to any method that you want available your web page code (the method must also be public). If you do not provide the annotation, then the method will not accessible by your web page when running on Android 4.2 or higher.

来源:的Andr​​oid的WebView文档

这篇关于Javascript的接口不工作与Android 4.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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