WebView: accessing JavaScriptInterface from multiple pages
In a WebView, how do you access the JavaScriptInterface from multiple web pages, and not just from the page that you load via mWebView.loadUrl(…)
e.g.
In my project's assets folder, I have:
index.html
page1.html
page2.html
... and here is the relevant WebView code:
webView.addJavascriptInterface(new JavaScriptInterface(), "android");
webView.loadUrl("file:///android_asset/index.html");
So at different points in time, a us开发者_JAVA技巧er may look at index.html, page1.html, etc. From what I can tell, only the JavaScript in index.html has access to the JavaScriptInterface via "window.android.someMethodName()". When I try to make a call to "window.android.someMethodName()" from page1.html, it says that "window.android" is not defined.
精彩评论