
Public static int TYPE_NOT_CONNECTED = 0 There is also method getConnectivityStatusString which returns current network state as a more readable string. Similarly for mobile data network is returns TYPE_MOBILE.


If wifi is enabled, this method will return TYPE_WIFI. It has method getConnectivityStatus which returns an int constant depending on current network connection. Now check following utility class NetworkUtil. Permissions required to access network state: Add following permission to your AndroidManifest.xml file. Here is a simple code snippet that will help you identify what kind of internet connection a user has on her device.įirst we need following permission in order to access network state. For example is wifi currently enabled? or is mobile data network is connected. You might also want to check what kind of internet connection is available in handset. Hence its always a good idea to check the network state before performing any task that requires internet connection. While doing so there is a chance that internet connection is not available on users handset. If you are developing an Android app you may already fetching information from internet.
