What is Android Connectivity Manager?
The ConnectivityManager provides an API that enables you to request that the device connect to a network based on various conditions that include device capabilities and data transport options.
How to check network connectivity in android programmatically?
We can check if the device is connected to wifi or a cellular network by using the hasTransport() method of NetworkCapabilities class. transportType for the cellular network is TRANSPORT_CELLULAR and wifi is TRANSPORT_WIFI.