public static boolean isNetworkConnected(Context context){
  if (null == context) {
    return false;
  }
  ConnectivityManager connectivityManager=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  if (connectivityManager != null) {
    NetworkInfo info=connectivityManager.getActiveNetworkInfo();
    if (info != null && info.isConnected()) {
      if (info.getState() == NetworkInfo.State.CONNECTED) {
        return true;
      }
    }
  }
  return false;
}

public static boolean isNetworkConnected ( Context context ) { if ( null == context ) { return false ; } ConnectivityManager connectivityManager = ( ConnectivityManager ) context . getSystemService ( Context . CONNECTIVITY_SERVICE ) ; if ( connectivityManager != null ) { NetworkInfo info = connectivityManager . getActiveNetworkInfo ( ) ; if ( info != null && info . isConnected ( ) ) { if ( info . getState ( ) == NetworkInfo . State . CONNECTED ) { return true ; } } } return false ; }
whether the network is connected
