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)