Detect whether there is an Internet connection available on Android

person shubham sharmafolder_openAndroidlocal_offer, access_time March 11, 2017

The getActiveNetworkInfo() method of ConnectivityManager returns a NetworkInfo instance representing the first connected network interface it can find or null if none of the interfaces are connected. Checking if this method returns null should be enough to tell if an internet connection is available or not.


 

You will also need:

 

in your android manifest.

warningComments are closed.