In my Android app, I have need to show a webpage in a WebView, using the URL obtained from my server. However, it sometimes shows OK but sometimes shows an error page (a .NET-style yellow page stating “Server Error in /Web Application”).
I want to do something in my app to identify that error and redirect to another page, but how do I recognize the error?
See How to retrieve HTML content from WebView (as a string)
Check the HttpResponse code and see if there’s error returned.
Take note of the comment to avoid consuming double of the bandwidth required, make a HttpRequest and load it into the WebView if there’s not error.