Add this Webview client class to your activity.
class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
view.loadUrl("about:blank");
super.onReceivedError(view, errorCode, description, failingUrl);
}
}
And call this class like this.
mWebView.setWebViewClient(new MyWebViewClient());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…