在android级别17之前将数据传递给webview中的javascript(4.2.2) [英] passing data to javascript in webview before android level 17 (4.2.2)
问题描述
我正在研究从android调用的javascript中的一些图表库。
I am working on some charting library in javascript that call from android.
了解JavascriptInterface仅在Android API等级17之后可用(4.2.2)
Understand that JavascriptInterface only available after Android API Level 17 (4.2.2)
http://developer.android.com/reference/android/webkit/JavascriptInterface.html
我想在4.2.2之前支持Android设备
I want to support android device before 4.2.2
无论如何将json传递给javascript?
is there anyway to pass a json to javascript?
推荐答案
了解JavascriptInterface仅在Android API Level 17(4.2.2)之后可用
Understand that JavascriptInterface only available after Android API Level 17 (4.2.2)
addJavascriptInterface()
自API等级1以来一直存在。你要链接到的是 @JavascriptInterface
注释,自API级别17以来一直存在。这些都与您的问题无关。
addJavascriptInterface()
has been around since API Level 1. What you are linking to is the @JavascriptInterface
annotation, which has only been around since API Level 17. Neither of these things have anything to do with your problem.
无论如何将json传递给javascript?
is there anyway to pass a json to javascript?
在API等级19+上,使用 evaluateJavascript()
。在API等级18及以下版本中,使用 loadUrl(javascript:)
,使用与桌面浏览器上的bookmarklet相同的基本语法。
On API Level 19+, use evaluateJavascript()
. On API Level 18 and below, use loadUrl("javascript:")
, using the same basic syntax used for bookmarklets on desktop browsers.
这篇关于在android级别17之前将数据传递给webview中的javascript(4.2.2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!