Android WebViewClient, onErrorReceived is not called when there is 404

I have a WebView with a WebViewClient that defines onErrorReceived and onPageFinished.

The onPageFinished function is called correctly, so I know that the WebViewclient is correctly bound to the WebView. However, there is some javascript in the WebView that calls:

location.href="http://kernel.org/asdf/asdf/asdf/asdf";

And the onErrorReceived listener is not called even if it is 404. Does it work with javascript calls?

Edit: after some testing, I found that NO 404s is being reported to this function at all. I have a test project created here: http://vimtips.org/media/WebViewTest.zip

It seems that this method cannot be used for testing 404. Does anyone know a way to do this?

+3
source share
2 answers

It's impossible. At least not in a hacker manner.

+1
source

Following the situation , onErrorReceived is called.

  • ERROR_AUTHENTICATION Error authenticating user on server
  • ERROR_BAD_URL Invalid URL
  • ERROR_CONNECT Failed to connect to server
  • ERROR_FAILED_SSL_HANDSHAKE SSL verification failed.
  • ERROR_FILE Shared file error
  • ERROR_FILE_NOT_FOUND File not found.
  • Error ERROR_HOST_LOOKUP Server or proxy server name error.
  • ERROR_IO Failed to read or write to server
  • ERROR_PROXY_AUTHENTICATION Error authenticating user in proxy server
  • ERROR_REDIRECT_LOOP Too many redirects
  • ERROR_TIMEOUT Connection timeout
  • ERROR_TOO_MANY_REQUESTS Too many requests during this download
  • ERROR_UNKNOWN General error
  • ERROR_UNSUPPORTED_AUTH_SCHEME Unsupported authentication scheme (not basic or digest)
  • ERROR_UNSUPPORTED_SCHEME Unsupported URI Schema

In fact, none of the HTTP response codes are listed above.

+2
source

All Articles