I have a webview. I want to call JS function from Java and assign return value to a variable.
This line from java calls getUserDetails() function of JavaScript.
webview.loadUrl("javascript:window.getUserDetails()");
This is the getUserDetails function in javascript which returns a string
window.getUserDetails = function(){
return "username";
}
I want to achieve something like this.
String user = webview.loadUrl("javascript:window.getUserDetails()");
How can I able to achieve this?