G-ShadoW Active Member Licensed User Longtime User Sep 2, 2015 #1 Hello, how to intercept this error in webview, I have searched whole forum and didnt found working example. Code: <!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
Hello, how to intercept this error in webview, I have searched whole forum and didnt found working example. Code: <!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 Sep 2, 2015 #2 What did you expect? the image does not exists... Error 404. Upvote 0
G-ShadoW Active Member Licensed User Longtime User Sep 2, 2015 #3 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 example.zip 159.5 KB · Views: 655 Upvote 0
here is project it's teletext and I want to avoid blank screen, to detect if site or in this case gif not exist
warwound Expert Licensed User Longtime User Sep 3, 2015 #4 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
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.
Erel B4X founder Staff member Licensed User Longtime User Sep 3, 2015 #5 The simplest way is to use HttpUtils2 and check whether the request is successful or not. Upvote 0