Android webview after onJsAlert not responding taps

android, jquery-mobile

Solution

I just faced the exactly same problem. I wanted to generate a custom android dialog instead of the alert, to this is the final solution:

myWebView.setWebChromeClient(new WebChromeClient() {
    @Override
    public boolean onJsAlert(WebView view, final String url, String message,
            JsResult result) {

        AlertDialog.Builder builder = new AlertDialog.Builder(
                MainActivity.this);
        builder.setMessage(message)
                .setNeutralButton("OK", new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        arg0.dismiss();
                    }
                }).show();
        result.cancel();
        return true;
    }
});

The key is the `result.cancel();` and `return true;`, I tested in several combinations, and the only one that did not fired the default JS alert AND didn't caused the touch problem was this combination

Problem

I have override my WebChromeClient's onJsAlert behavior like: ``` WebChromeClient wvcc = new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, String message, final JsResult result) { //... return true; } } ``` my application successfully handle the Js alerts and suppressed the original alert. However, after the alert event, I can no longer click my buttons(in list-items of listview) on the web page in my webview. I am currently using jquery mobile to build my web. Is there anything else I should aware of?

Original source