When does onProgressChanged get to 100?

1.1k views Asked by At

In my android application, I have a webview that loads a javascript file.

The javascript in turn loads a few images.

//javascript file

var imageObj = new Image();
imageObj.onload = function() {
    // my images is fully loaded
    console.log("image is loaded!");
}
imageObj.src = src;

I would like to display the webview when all images finished loading but it seems like onProgressChanged is called too early with newProgress == 100.

//java

@Override
public void onProgressChanged(WebView view, int newProgress) {
    super.onProgressChanged(view, newProgress);

    if (newProgress == 100) {
       mDecorView.addView(view);
       // this is called, but I see the that sometimes the webview didn't finish loading all images.
    }
}

When is this event called?

Is there a better alternative to achieve this?

1

There are 1 answers

1
Md Abdul Gafur On

Can you try this . May be help you.

android Webview WebViewClient class that have

public void onPageFinished(WebView view, String url) {

// TODO Auto-generated method stub
super.onPageFinished(view, url);

}

Method.