public static boolean isOnline ( Context context ) { ConnectivityManager cm = ( ConnectivityManager ) context . getSystemService ( Context . CONNECTIVITY_SERVICE ) ; if ( cm == null ) { return false ; } NetworkInfo info = cm . getActiveNetworkInfo ( ) ; return info != null && info . isConnectedOrConnecting ( ) ; }
Checks whether there s a network connection .