Chapter 9. Network communication with push notifications and sockets
This chapter covers
In the past few years, the way that most mobile users use their phones has dramatically changed. The mobile phone has become our constant companion and helps keep us connected with family, friends, and coworkers. We use the phone to read news, check emails/twitter/Facebook, post updates, and play games. Most of the applications that you’re using on your phone have one thing in common. Can you guess what it is? All those applications access the network to retrieve the information stored in the cloud. Consuming resources from the network is crucial even for a normal mobile user. As a developer who is developing an application for mobile devices, you need to understand how to efficiently consume network resources.
Networked applications need to know whether a network connection is available, and if so, what type of connection is enabled. We open up this chapter by discussing how you can detect the network connection before consuming resources. We show you how to detect whether the device is connected to a cellular data network or a Wi-Fi access point, or whether the device is in airplane mode.