iOS and Android custom “no signal” messages (WARNING, this blog-post includes code)

When I use an app, the last thing I want to see is a “cannot connect/404” sort of message. Besides the frustration of not getting to the information I desire, it makes the coder appear sloppy! I mean, come on, do you really use web pages for every button in your app?

Ugh, actually, I may do that from time-to-time. It’s sometimes a necessity. Sometimes I don’t have all the information 6 weeks out, and Apple can take that long just to approve an app! So linking to webpages is sometimes the best I can do.

So what happens when the user clicks on a button, and cannot connect??


First create your own error page in HTML and put it in your assets folder, Let’s call it myerrorpage.html Then with onReceivedError, use the following:

mWebView.setWebViewClient(new WebViewClient() {
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {


I used this code in an app for a conference. The HTML had a logo of the app sponsor, as well as a message for how to get a connection in the hotel hosting the conference. It is neat, tidy, and does give a sloppy appearance. Seriously, if I left the app with going to the 404 page, I’m pretty sure I wouldn’t be hired again to write an app!

(I actually gave this response on, so if you find it useful, please click this link and give me an up vote!…my Stackoverflow handle is SnowboardBruin.)


-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
     [activity stopAnimating];  
     if (error != NULL) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Connection?"
message:@"Use network ID: CONFERENCE CYBERSPOT\nTo get your username and password, please visit the Sponsor Cyberspots in the SW of the conference."


[alert show];
[alert release];


The iOS code above is a popup message rather than an HTML page, so you can see the instructions here.

While this is not a requirement for building an app, it’s something nice you can do for your users, and it’s these nice little “bells and whistles” that will keep your clients coming back!

Good luck, and happy coding!