Introduction to Android Networking, Client Server
Android lets your application connect to the internet or any other local network and allows you to perform network operations. A device can have various types of network connections. This chapter focuses on using either a Wi-Fi or a mobile network connection. Checking Network Connection Before you perform any network operations, you must first check that are you connected to that network or internet e.t.c. For this android provides ConnectivityManager class. You need to instantiate an object of this class by calling getSystemService() method. Its syntax is given below − ConnectivityManager check = ( ConnectivityManager ) this . context . getSystemService ( Context . CONNECTIVITY_SERVICE ); Once you instantiate the object of ConnectivityManager class, you can use getAllNetworkInfo method to get the information of all the networks. This method returns an array of NetworkInfo . So you have to receive it like this. NetworkInfo [] ...


Comments
Post a Comment