Android的WebViewClient,onErrorReceived不会被调用时,有一个404 [英] Android WebViewClient, onErrorReceived not being called when there is a 404

查看:532
本文介绍了Android的WebViewClient,onErrorReceived不会被调用时,有一个404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web视图,以WebViewClient定义onErrorReceived和onPageFinished。

I've got a WebView, with a WebViewClient that defines onErrorReceived, and onPageFinished.

在onPageFinished被调用正确的,所以我知道WebViewclient是否正确连接到的WebView。然而,有一个在web视图一些JavaScript调用:

The onPageFinished gets called correctly, so I know that the WebViewclient is attached to the WebView correctly. However, there's some javascript in the WebView that calls:

location.href =htt​​p://kernel.org/asdf/asdf/asdf/asdf;

而onErrorReceived听者不叫,即使它是一个404这岂不是用JavaScript调用工作?

And the onErrorReceived listener is not called, even though it's a 404. Does it not work with javascript calls?

编辑:经过一些测试,我发现没有404报告给这个函数任何责任。我有一个测试项目设在这里: http://vimtips.org/media/WebViewTest.zip

After some testing, I have found that NO 404s are reported to this function whatsoever. I have a test project set up here: http://vimtips.org/media/WebViewTest.zip

似乎这种方法不能用于测试404。任何人都知道的一种方式做到这一点?

It appears that this method cannot be used to test for 404s. Anyone know of a way to do this?

推荐答案

它不能这样做。至少,不是在非哈克方式

It can't be done. At least, not in a non-hacky way.

这篇关于Android的WebViewClient,onErrorReceived不会被调用时,有一个404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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