Now I need to use webview component to load a HTML page and deal with component function. The content in HTML page is ,
you can see there is a multi-object (webkit.messageHandlers.adClicked), how could I to use webView.addJavascriptInterface() function to deal with it? I know how to deal with single object, but I don't know how to deal with multi-object?
I use following code, but it does not work:
enter code here
webView.addJavascriptInterface(this, "webkit");
webView.addJavascriptInterface(this, "messageHandlers");
webView.addJavascriptInterface(this, "adClicked");
webView.addJavascriptInterface(this, "webkit.messageHandlers.thepaperNewsClicked");
@android.webkit.JavascriptInterface
public void postMessage(final String str) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getContext(), "param:" + str, Toast.LENGTH_SHORT).show();
}
});