Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if WebView is fully rendered and ready to go?

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.

like image 841
LoomyBear Avatar asked Aug 23 '12 07:08

LoomyBear


1 Answers

You need

mWebView.setWebViewClient(new WebViewClient() {
 public void onPageFinished(WebView view, String url) {
     // your code    
 } 
}); 
like image 152
s_bei Avatar answered Sep 22 '22 14:09

s_bei