Am using webview to load a page in android. Once the page is loaded, localstorage is updated. I want to retrieve data from it. Above kitkat, using evaluateJavascript am able to obtain the data. It have a callback. The problem is with versions below kitkat, where i have to use loadUrl() for it.
loadUrl("javascript:localStorage.getItem('"+ key +"')");
I want to pass the value returned by function getItem(), to calling activity.
you can do it. First you need to add javascript interface to your webview like this. Lets say you are loading url in some activity called FormDetailActivity:
formBridge is the instance of a class where all the methods are written that are being called from js.
And to pass the key from java to your js you need to make a method in js accepting key param and then you can call it like this:
And then call this method from your js like: