I am working on a heavily webview dependant application. Load times are decent now after optimizations on my web code, but its nowhere near speeds of a native app.
I wonder if its possible to store frequently used Javascript in the app itself, rather than loading it everytime from the server. Maybe a way to store/load that Javascript on the Webview.
Just override the onPageFinished method from WebViewClient. This method is called when the page is finished loading, then you can inject JavaScript from your app via one of these two calls, depending on the version of Android.
For KITKAT and above use: webView.evaluateJavascript(jsString, null);
Where jsString is your string of JavaScript code.
For Android versions below KITKAT use: webView.loadUrl("javascript:" + jsString);
Again, where jsString is your string of JavaScript code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.