How do we call javascript from Android? I have this javascript library which I would like to use, I want to call the javascript function and pass the result value to the android java code. Haven’t found the answer from now. i managed to call android code from javascript, but I want the other way around.
Share
There is a hack:
Bind some Java object so that it can be called from Javascript with WebView:
Force execute javascript within an existing page by
(in this case your java class
JavaObjectCallbackshould have a methodreturnResult(..))Note: this is a security risk – any JS code in this web page could access/call your binded Java object. Best to pass some one-time cookies to loadUrl() and pass them back your Java object to check that it’s your code making the call.