1

I have a WebView in my application and I do a search on google. When I click a link there, let's say stackoverflow.com, it redirects me to a white page and the url is about:blank (new tab?). I already tried this

webview.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;
        }
    });

but it does not have any effect on this behaviour. Can anyone help me?

Phil
  • 943
  • 2
  • 6
  • 18

2 Answers2

1

That normally happens while accessing https URLs which have untrusted certificates. Have you tried this yet?

webview.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return false;
    }
    @Override
    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
        handler.proceed(); // Ignore SSL certificate errors
    }
});
Bidhan
  • 10,607
  • 3
  • 39
  • 50
  • I just tested it now and I still have the same problem :/ And I just checked it also happens with non https sites – Phil May 24 '15 at 17:29
1

I just fixed it with this post here

    @Override
public void onPageFinished(WebView view, String url)
{
    System.out.println("onPageFinished: " + url);
    if ("about:blank".equals(url) && view.getTag() != null)
    {
        view.loadUrl(view.getTag().toString());
    }
    else
    {
        view.setTag(url);
    }
}
Community
  • 1
  • 1
Phil
  • 943
  • 2
  • 6
  • 18