Ответ 1
Вы должны использовать как WebViewClient, так и WebChromeClient.
WebChromeClient позволяет, например, получить ход загрузки, тогда как WebViewClient позволит вам переопределить shouldOverrideUrlLoading().
На странице веб-страницы:
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});