How to check Network Connectivity Status in Android

In this post, we will see how to check the Network Connectivity Status in Android. Our app may have to behave differently based on the network it is connected i.e wifi,mobile,vpn etc., To check the network connectivity info, we use the ConnectivityManager and NetworkInfo class of android net package.

The below snippet demonstrates how to detect whether the mobile is connected to WIFI or Mobile data.

Code Snippet: