Webview not able to load https url in android?

前端 未结 9 1287
别跟我提以往
别跟我提以往 2020-12-29 08:14

I am implementing webview application in android. When i am trying to load https url one or two times it finishes the activity. Agian tryin

相关标签:
9条回答
  • 2020-12-29 08:42

    Add this overriding method to your WebViewClient implementation. You'll need to compile it with Android SDK 2.2 (API level 8) or later. The method appears in the public SDK as of 2.2 (API level 8) but we've tested it on devices running 2.1, 1.6 and 1.5 and it works on those devices too (so obviously the behaviour has been there all along).

    WebView.setWebViewClient(new WebViewClient() {
    
         public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error){
    
             handler.proceed(); 
    
         }
        });
    
    0 讨论(0)
  • 2020-12-29 08:44

    Delete this string:

    super.onReceivedSslError(view, handler, error);
    

    and in this method

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
    

    turn return to false
    like this:

     return false;
    

    It helped me

    0 讨论(0)
  • 2020-12-29 08:46

    One possibility here is a race condition.

    You are loading https://www.facebook.com/ before setting up the WebViewClient, so there is a possibility that your implementation of OnReceivedSslError() will never get called if you get a quick enough response from facebook.

    This would explain why it works for some people, not for others, and always works if the page is reloaded.

    Also, I think you should just be returning false from shouldOverrideUrlLoading() if you want the page to load rather than attempting to reload the page - this might cause an infinite recursion / crash - possibly depending upon timing.

    0 讨论(0)
提交回复
热议问题