SslErrorHandler.cancel() is not working when call manually in android

366 Views Asked by At

I am getting error in

@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
}

for handle this error i created a alert dialog with following code:-

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);

    builder.setMessage("SSL Certificate Error" + "\n" + "Do you want to continue anyway?");
    builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handler.proceed();
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handler.cancel();
        }
    });

    final AlertDialog dialog = builder.create();
    dialog.setTitle("Alert");
    dialog.show();

But on cancel button of dialog handler.cancel(); is not working. page load process is not canceled after calling handler.cancel();

can anyone please help

1

There are 1 best solutions below

0
On

Did you try this one?
webview.stopLoading();
I had the same problem, but it worked in my case.