Wednesday, January 30, 2013

Check Network Connectivity for Android

Following code for check Net Connectivity on android:


public static boolean IsNetworkAvailable(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);    
         NetworkInfo networkInfo = cm.getActiveNetworkInfo();    
         if (networkInfo != null && networkInfo.isConnected())
         {        
                      return true;    
          }    
  return false;

No comments:

Post a Comment