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


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?


I have solved this problem by implementing the setWebChromeClient:

webView.setWebChromeClient(new WebChromeClient() {

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

Answered By – Mukesh Y.

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *