Code example for NetworkInfo.State

Methods: equals

0
      if (mgr == null) {
         throw new UnsupportedOperationException("Error, ConnectivityManager cannot be null");
      } 
      NetworkInfo netInfo = mgr.getActiveNetworkInfo();
      if ((netInfo != null) && (netInfo.getState() != null)) {
         return netInfo.getState().equals(State.CONNECTED);
      } 
      return false; 
   } 
 
   public static boolean wifiConnectionPresent(ConnectivityManager mgr) {
      if (mgr == null) {
         throw new UnsupportedOperationException("Error, ConnectivityManager cannot be null");
      } 
      NetworkInfo netInfo = mgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
      if ((netInfo != null) && (netInfo.getState() != null)) {
         return netInfo.getState().equals(State.CONNECTED);
      } 
      return false; 
   } 
Stop searching for code, let great code find you!  Add Codota to your java IDE