【发布时间】:2019-03-01 18:07:47
【问题描述】:
有没有人知道有没有办法在 WebView 中拦截“页面未找到”或“页面未加载错误”?
根据android文档,onReceivedError()应该可以拦截。但我在一个应用程序中测试了它,我故意给出了错误的 URL,它没有做任何事情。
如果 URL 由于任何原因不可用,我希望我的应用能够提供我自己的自定义错误消息。
这是什么都没做的代码:
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// custom error handling ... show and alert or toast or something
}
【问题讨论】: