The question is a bit unclear about where the call is being invoked. If you want to execute Java (android) functions in JavaScript, then you must create an Interface.
Here is an example of emulating an alert() function using an Interface.
public class JavaScriptInterface { Context mContext; JavaScriptInterface(Context c) { mContext = c; } /** Show a toast from the web page */ @JavascriptInterface public void showToast(String toast) { Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show(); } } //at the oncreate of your activity where webviews is being created WebView myWebView = findViewById(R.id.sidmyWebView); myWebView.addJavascriptInterface(new JavaScriptInterface(this), "Android"); //this name will be used in JS myWebView.getSettings().setAllowFileAccess(true); myWebView.clearCache(true); //temporary for css reload WebSettings myWebSettings = myWebView.getSettings(); myWebSettings.setJavaScriptEnabled(true); //this enables js on this page //now, in JS file execution, you can emulate the js alert function as //alert("Show toast"); //this will not show anything, as you noted Android.showToast("Calling Alert-show in Android WebView - Java/JavaScript"); //this will work
But if your requirement is simply the normal alerts/dialogues, then read on acceptable non-obstructive methods allowed by Android.