7

My problem is that sometimes I've got a blank-white webview for a couple of seconds instead of rendered HTML which is quite depressing. I want to implement some kinda listener to check if webview renders all the HTML. In other words: I want to make my webview blank-white proof.

I've already inserted the javascript simple trigger in the HTML that tells app when the HTML is fully loaded and ready to render:

$(window).load(function(){
     tellAndroidImReady();
});

It works perfect, but sometimes I'm getting this blank screen going for a couple of seconds instead of shiny rendered page. And this makes me crazy ...

I've made some searches on stackoverflow and found only this topic where it says that the part of the method that is used in the solution is deprecated so I guess it's not supposed to be correct.

1 Answer 1

13

You need

mWebView.setWebViewClient(new WebViewClient() {
 public void onPageFinished(WebView view, String url) {
     // your code    
 } 
}); 
3
  • 3
    I think your code is good but it does exactly the same thing as my javascript ... it tells android that $(window) is loaded . I'm still having a blank webview sometimes.
    – LoomyBear
    Aug 23, 2012 at 8:55
  • Anyway I've decided to choose your solution and check if page is loaded from the app and not from the HTML. App started to work much smoother. You're the man! Cheeeers! ;)
    – LoomyBear
    Aug 23, 2012 at 13:09
  • 1
    this won't work if there are any redirects...first redirect will cause onPageFinished to be called, but it'll be blank...
    – kenyee
    Aug 24, 2016 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.