如何从Android的WebView功能检查,如果一个网页是一个"未发现404页"? [英] How can I check from Android WebView if a page is a "404 page not found"?

查看:76
本文介绍了如何从Android的WebView功能检查,如果一个网页是一个"未发现404页"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查404找不到网页从web视图,如果它是一个404,然后我恢复到 previous页面。泰对你有所帮助。

I want to check a "404 page not found" from a WebView and if it's a 404 then I revert to the previous page. Ty for your help

编辑也是我想看到的网页是纯.JPG 1.JPG 2.JPG 3.JPG,但我有一个如何存在许多图像没有资料。因此,如果任何人都可以提出另一种方法,欢迎他这样做。

EDIT also the webpages I want to see are pure .jpg 1.jpg 2.jpg 3.jpg but I have no info of how many images exist. So if anyone can propose another method, he is welcome to do so.

推荐答案

附加 WebViewClient 的WebView ,在这里您可以覆盖 onReceivedError()来了解404的响应 - 尽管这可能会被返回 ERROR_FILE_NOT_FOUND

Attach a WebViewClient to your WebView, where you override onReceivedError() to find out about the 404 response -- though that will probably be returned as ERROR_FILE_NOT_FOUND.

这篇关于如何从Android的WebView功能检查,如果一个网页是一个"未发现404页"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆