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?
Can you try this . May be help you.
android Webview
WebViewClient
class that have}
Method.