It is possible. To execute JavaScript and get the answer, you can do the following:
Define the JavaScript callback interface in the code:
class MyJavaScriptInterface { public void someCallback(String jsResult) {
Attach this callback to your WebView:
MyJavaScriptInterface javaInterface = new MyJavaScriptInterface(); webView.addJavascriptInterface(javaInterface, "HTMLOUT");
Run the JavaScript.HTMLOUT.someCallback call window from the script:
webView.loadUrl("javascript:( function () { var name = window.localStorage['name']; window.HTMLOUT.someCallback(name); } ) ()");
Note. window.localStorage['name'] same as window.localStorage.getItem('name')
fooobar.com/questions/372759 / ...
You may need super.webView.addJavascriptInterface or super.addJavascriptInterface to add an interface. You may need to use super.webView.loadUrl or super.loadUrl to call this. It all depends on where you are going to call.
source share