webview communicate java android studio
//Activity (Java)
import android.webkit.JavascriptInterface;
webView.addJavascriptInterface(new WebAppInterface(this), "Android");
public class WebAppInterface{
Context mContext;
/** Instantiate the interface and set the context */
WebAppInterface(Context c) {
mContext = c;
}
@JavascriptInterface // must be added for API 17 or higher
public void ApplicationClose() {
//something
}
}
//Webview (Javascript)
Android.ApplicationClose();