Android webview: How to change JavaScript alert title text in android webview?

android, java, javascript, webview

Solution

I have solved this problem by implementing the setWebChromeClient:

webView.setWebChromeClient(new WebChromeClient() {

    @Override
    public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
        AlertDialog dialog = new AlertDialog.Builder(view.getContext()).
                setTitle("YourAlertTitle").
                setMessage(message).
                setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //do nothing
                    }
                }).create();
        dialog.show();
       
        return true;
    } }); 

Problem

In my Android application I have used web view inside web view I have a button. On clicking that button I am calling a JavaScript function that JavaScript function have an alert box. In that alert title is showing (The page at "file://" says). I want to change this title to my custom text. How to change that title?

Original source

Related problems