Android: Detect when a WebView has finished loading

To know when a WebView has finished loading, you can set a WebViewClient() handler and override the onPageFinished() method.

ProgressDialog progressDialog = new ProgressDialog(ResultActivity.this);
progressDialog.setMessage("Loading ...");

progressDialog.setCancelable(false);
progressDialog.show();

WebView wv = new WebView(this);

wv.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressDialog.hide();
}
});

wv.loadUrl(some_url);

This example shows a "loading dialog" while the webview loads in the background. It'll go away once the page has fully loaded.

1246086511568

Just like when the Jedi warriors have finished defeating enemies, at the end of the battle they force push a fat dude off his chair.

Source

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog