Adam Johns Adam Johns - 1 year ago 104
Android Question

WebView must be loaded twice to load correctly

When the page with the WebView first loads, sometimes images are missing or displayed incorrectly. If I reload the page the WebView always displays perfectly. I know everyone will first think I set javascript after loadUrl, but that isn't true.

In onCreate I have:

learnWebView = (WebView)findViewById(;
learnWebView.setWebViewClient(new WebViewClient());

Then later in the function called after onCreate I have:


And yes, I know that the function with loadUrl is called after onCreate every time.

Answer Source

I haven't seen this issue since overriding shouldOverrideUrlLoading in WebViewClient

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

Although I'm uncertain as to why this would make a difference, because returning false is just supposed to make your WebView handle all url openings.