4
votes

I created an Android WebView app on Android 4.3 which firstly opens a log in page and after that it should link me to a https page, but instead of opening the https page it says "Web page not available". I tried to open the same with the web browser and firstly opens "The site's security certificate is not trusted!" and after pressing to proceed the page opens.

Though I used:

    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
    {                          
        handler.proceed(); 
    }

the WebView still won't open the https page. Is there any possible way to open the https page in the webview? Could you please help me?

1
related: stackoverflow.com/questions/7416096/… ; is the onReceivedSslError() method is called? if not this is probably not just a certificate problem.Stéphane
I've already checked the related link you've posted but no success. The onRecievedSslError is called.user3495863
Did you solve your problem?Accollativo

1 Answers

5
votes
    webView=(WebView)findViewById(R.id.webView);
    WebSettings webSettings=webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webView.setWebViewClient(new MyWebViewClient());
    webView.loadUrl("your https url here");

    private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        webView.loadUrl(url);
        return true;
    }

    @Override
    public void onReceivedSslError(WebView view, SslErrorHandler handler,
                                   SslError error) {
        super.onReceivedSslError(view, handler, error);
        handler.proceed();
    }
}