onPageFinished not firing correctly when rendering web page
I had a project that had code which needed to run only after the webview had displayed it's content, and like you, onPageFinished() wasn't working. It fired too quickly, before the webview had actually rendered the page.
Instead, I had to use a "PictureListener" which gets fired when the webview actually updates the screen.
You use it like so:
mWebView.setPictureListener(new MyPictureListener());
//... and then later on....
class MyPictureListener implements PictureListener {
@Override
public void onNewPicture(WebView view, Picture arg1) {
// put code here that needs to run when the page has finished loading and
// a new "picture" is on the webview.
}
}
I had the same problem to dismiss my progressdialog when rendering my web page. I solved with onPageStarted. I hope this solution can help you.
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressBar.dismiss();
}
@Override
public void onPageStarted(WebView view, String url,
android.graphics.Bitmap favicon) {
if (!progressBar.isShowing()) {
progressBar.show();
}
};