Tuesday, July 14, 2020

How to check Internet Connection in Android

How to check Internet is Connected or not In Android

In Android Internet Connection can be checked by using  ConnectivityManager class.

Note : to use this you need to declare ACCESS_NETWORK_STATE 

Android Manifest

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 


boolean isInternetConnected()

   ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE );

   NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
   boolean isConncted = activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting();

   return isConncted;

1 comment:

  1. Clearly, It is an engaging blog for us that you have provided here about Voip Internet Service This is a great resource to enhance our knowledge about it. Thank you.