Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. Building for the Mobile Web > Network Type Detection and Handling

Network Type Detection and Handling

Now that we have the ability to buffer (or predictive cache) the example web app, we must provide the proper connection detection features to make the app smarter. This is where mobile app development gets extremely sensitive to online/offline modes and connection speed. Enter the Network Information API. With it, you can set up an extremely smart mobile web app.

When would this be useful? Suppose someone on a high-speed train is using your app to interact with the Web. As the train rushes along, the network may very well go away at various moments, and various locales may support different transmission speeds (HSPA or 3G might be available in some urban areas, while remote areas might support much slower 2G technologies only). Not only does the following code address connection scenarios like this, it also:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint