开发者

Android WebViewClient, onErrorReceived not being called when there is a 404

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

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="http://kernel.org/asdf/asdf/asdf/asdf";

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

Edit: After some tes开发者_StackOverflow社区ting, 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

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


In following situation, onErrorReceived will be called.

  • ERROR_AUTHENTICATION User authentication failed on server
  • ERROR_BAD_URL Malformed URL
  • ERROR_CONNECT Failed to connect to the server
  • ERROR_FAILED_SSL_HANDSHAKE Failed to perform SSL handshake
  • ERROR_FILE Generic file error
  • ERROR_FILE_NOT_FOUND File not found
  • ERROR_HOST_LOOKUP Server or proxy hostname lookup failed
  • ERROR_IO Failed to read or write to the server
  • ERROR_PROXY_AUTHENTICATION User authentication failed on proxy
  • ERROR_REDIRECT_LOOP Too many redirects
  • ERROR_TIMEOUT Connection timed out
  • ERROR_TOO_MANY_REQUESTS Too many requests during this load
  • ERROR_UNKNOWN Generic error
  • ERROR_UNSUPPORTED_AUTH_SCHEME Unsupported authentication scheme (not basic or digest)
  • ERROR_UNSUPPORTED_SCHEME Unsupported URI scheme

Actually, none of HTTP response codes are in the list above.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜