webview intermodulation

Webview

The intermodulation of Webview is divided into two types: native js and js native;

1. Native tuning js : logic with parameters but no return value: through webview.loadUrl( "javaScript: method name ( if the parameter is of string type, single quotes are required ) ");

The logic of no parameter and return value: through webview.evaluateJavaScript( method name (), new ValueCallback<>(){})

2, js tune native: webview.addJavaScriptInterface(context, "marker") is required when initializing webview ,

Js uses this tag to call native ( window. tag . native method name), and the native method needs to be annotated with @JavascriptInterface ;

The kernel of Webview before 4.4 is webkit , the kernel of webview in 4.1--4.3 has not changed, but the framework layer introduces the factory mode, the purpose is to separate the kernel and the upper -level API interface, the meaning of separation is not only abstract interface, but also to replace webview Partial implementation of the kernel. In 4.4 , the webview kernel was replaced with chromium ;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324719516&siteId=291194637