Android Question WebView error 404 source html body

G-ShadoW

Active Member
Licensed User
Longtime User
Hello, how to intercept this error in webview, I have searched whole forum and didnt found working example.

B4X:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /images/917-01.gif was not found on this server.</p>
</body></html>

url used: http://teletekst1.hrt.hr/images/917-01.gif
 

DonManfred

Expert
Licensed User
Longtime User
What did you expect? the image does not exists... Error 404.
 
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
here is project

it's teletext and I want to avoid blank screen, to detect if site or in this case gif not exist
 

Attachments

  • example.zip
    159.5 KB · Views: 452
Upvote 0

warwound

Expert
Licensed User
Longtime User
There's a java solution on this page: http://twigstechtips.blogspot.co.uk/2013/01/android-override-default-webview-error.html.
You need to set a WebViewClient and override the WebViewClient's onReceiveError callback.

B4A's WebView has a WebViewClient set but it does not override the onReceiveError callback.

My WebViewExtras2 library allows you to set a WebViewClient that overrides the onReceiveError callback.
When an error occurs it raises the event:

ReceivedError (ErrorCode As Int, Description As String, FailingUrl As String)

So you can listen for that event, look at the error code and display a custom error page.

WebViewExtras2 can be downloaded from here: http://b4a.martinpearman.co.uk/webviewextras/WebViewExtras2-v2.10.zip

And a forum search for ReceivedError shows some results that may be useful.
 
Upvote 0
Top