WebView must be loaded twice to load correctly

后端 未结 3 1611
一生所求
一生所求 2020-12-11 07:03

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 everyon

相关标签:
3条回答
  • 2020-12-11 07:30

    Please try this instead of your way, that is a bad practice:

            learnWebView.post(new Runnable() {
    
                @Override
                public void run() {
                    learnWebView.loadUrl("myurl");
                }
            });
    

    Or this, in case the first one wont work:

            learnWebView.postDelayed(new Runnable() {
    
                @Override
                public void run() {
                    learnWebView.loadUrl("myurl");
                }
            }, 500);
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-11 07:32

    I met the same issue. not sure if it is the same case as yours. I spent more than 3 days and actually found the cause it that another WebView object calls pauseTimers() for saving some CPU performance which actually " Pauses all layout, parsing, and JavaScript timers for all WebViews."

    0 讨论(0)
  • 2020-12-11 07:39

    Look at onViewAttachedToWindow. You should process your logic in javascript only after onViewAttachedToWindow fired.

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