0

I'm developing a browser-like application in android using WebView. While loading the URL, I want to display a specific page/message/toast whenever server returns 404 response. I tried using shouldOverrideUrlLoading, but it can filter URLs based on URL string only. Is there any good way to get the server's response code within WebViewClient or WebChromeClient (without loading the URL twice)?

PC.
  • 6,870
  • 5
  • 36
  • 71
  • Be more explicit. You don't intercept the url in shouldOverrideUrlLoading ? – Snicolas Apr 06 '12 at 09:54
  • @Snicolas all i want is to get the event when 404 error is obtained. – PC. Apr 06 '12 at 10:04
  • 1
    Webviewclient has a method onPageError or something like this. Is it what you are looking for ? http://stackoverflow.com/questions/4997677/android-webview-onreceivederror – Snicolas Apr 06 '12 at 10:12

1 Answers1

-1

override the method onReceivedError of WebViewclient

PC.
  • 6,870
  • 5
  • 36
  • 71
  • Where is there an `onPageError` method in `WebViewClient`? It's not in the docs: http://developer.android.com/reference/android/webkit/WebViewClient.html – wsanville Aug 08 '12 at 18:27
  • its actually `onReceivedError`. http://developer.android.com/reference/android/webkit/WebViewClient.html#onReceivedError(android.webkit.WebView, int, java.lang.String, java.lang.String) (I've updated my answer) – PC. Aug 09 '12 at 02:19