我希望在接收到错误时能够显示来自本地资产的HTML。但是,即使我重写了onReceivedError方法,在从资产中获取页面之前,仍然会出现一个错误页面一闪而过。是否有解决此问题的修复或黑客方式?
以下是我的代码:
以下是我的代码:
@Override
public void onReceivedError (WebView view, int errorCode, String description, String failingUrl)
{
Log.i("onReceivedError", "onReceivedError: " + failingUrl + " errorCode: " + errorCode);
super.onReceivedError(view, errorCode, description, failingUrl);
view.stopLoading();
loadFromAsset(view, failingUrl);
}
onReceivedError
处理 HTTP 响应状态码。根据文档:向主机应用程序报告错误。...基本用法:..不启用 JavaScript 并忽略网页错误
。 - Boris MocialovHttpClient
,并处理HttpResponse.getStatusLine.getStatusCode
。 - Boris Mocialov