private static boolean getSystemConnectivity ( Context context ) { try { ConnectivityManager cm = ( ConnectivityManager ) context . getSystemService ( Context . CONNECTIVITY_SERVICE ) ; if ( cm == null ) { return false ; } NetworkInfo activeNetwork = cm . getActiveNetworkInfo ( ) ; return activeNetwork . isConnectedOrConnecting ( ) ; } catch ( Exception exception ) { return false ; } }
Get the connectivity state as reported by the Android system