Droid Man
Droid Man

Reputation: 21

How to block WebView in Android from converting 'https' to 'http'?

My WebView converts https to http, as evident from checking the url parameter in shouldOverrideUrlLoading() method. I have tried using

webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE), but it doesn't work.

How do I fix this? Please help!

Upvotes: 1

Views: 166

Answers (1)

Kirguduck
Kirguduck

Reputation: 796

you can handle every url as you wish just set up your webview via customized WebViewClient

webview.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView webView, String url) {
                if (url.startWith("https")) {                     
                    //do whatever you need
                    }
                    return false;
                }else if(....

Upvotes: 2

Related Questions