Load HTTPS Pages/URLs in Android Webview


It is a very common and known issue that we cannot load pages with the SSL in Android Webview. The solution to this could be varying from making code changes to the backend so that the service recognizes this situation and redirects to a non SSL based resources to overriding the onReceivedSslError method.

However, when we do not have control on the backend services, we somehow need to fix this from the tools that we have access to. In that case the obvious solution is to override the onReceivedSslError method. Paste the below code in your corresponding Activity class:

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

This will work just fine when you test your app in your phone or on the simulator. When you submit your app to the Play Store, you could possibly get the following Security alert

Security alert Your application has an unsafe implementation of the WebViewClient.onReceivedSslError handler. 

Rightly so, since you are doing this without letting the user know about the navigation from https to http. We will solve this issue in the next post.

See you around.
Share on Google+

About Sujit Horakeri

Sujit Horakeri is a game freak just like any other next door guy you would come across. He is a Web Developer by Profession, Game Developer by Choice.
    Blogger
    Facebook

7 comments:

  1. Very nice article.Keep posting. i will wait for your next article. Thanks!
    happy wheels 2.0

    ReplyDelete
  2. very impressive article. thanks for sharing it
    az baby names

    ReplyDelete
  3. Very informative article.it is written a well organized manner.it is really interesting to read this article.It contain so many vital information to the readers.Thank you for giving this good article to us.Visit custom dissertation online to get more articles like this.

    ReplyDelete
  4. This is the most important article for Android users.It informs us about the problem of Android webview. Thanks for posting this useful article.ourbdshop

    ReplyDelete
  5. Be positive article for android users and the vital information of android webview..Thanks for share it..https://ourbdshop

    ReplyDelete
  6. Incredible Article… I want to read your articles in light of the fact that your composition style is too great, it is extremely useful for us all and I never get exhausted while reading your article on the grounds that...CFA Audit
    Vendor Reconciliation
    CA Firms

    ReplyDelete
  7. Thanks so much for this great article; this is the kind of thing that keeps me going through the day.

    mutilateadoll23.com
    luffygames.com

    ReplyDelete