public static boolean testNetwork(Activity parentActivity){
  ConnectivityManager connMgr=(ConnectivityManager)parentActivity.getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo networkInfo=connMgr.getActiveNetworkInfo();
  return (networkInfo != null && networkInfo.isConnected());
}

public static boolean testNetwork ( Activity parentActivity ) { ConnectivityManager connMgr = ( ConnectivityManager ) parentActivity . getSystemService ( Context . CONNECTIVITY_SERVICE ) ; NetworkInfo networkInfo = connMgr . getActiveNetworkInfo ( ) ; return ( networkInfo != null && networkInfo . isConnected ( ) ) ; }
method to test the network connection
