I want to get a return value from Javascript in Android. I can do it with the iPhone, but I can't with Android. I used loadUrl, but it returned void instead of an object. Can anybody help me?
Same as Keith
but shorter answer
webView.addJavascriptInterface(this, "android");
webView.loadUrl("javascript:android.onData(functionThatReturnsSomething)");
And implement the function
@JavascriptInterface
public void onData(String value) {
//.. do something with the data
}
Don't forget to remove the onData
from proguard
list (if you have enabled proguard)