List of usage examples for android.net ConnectivityManager isNetworkTypeValid
@Deprecated public static boolean isNetworkTypeValid(int networkType)
From source file:Main.java
public static boolean isUsingWiFi() { return ConnectivityManager.isNetworkTypeValid(ConnectivityManager.TYPE_WIFI); }
From source file:Main.java
public static boolean isWIFIConnection(Context context) { return ConnectivityManager.isNetworkTypeValid(ConnectivityManager.TYPE_WIFI); }
From source file:Main.java
public static final boolean hasConnectivity(final Context context, final int... networkTypes) { final ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (networkTypes.length == 0) for (final NetworkInfo info : connectivity.getAllNetworkInfo()) if (info.isAvailable() || info.isConnected() || info.isConnectedOrConnecting()) return true; for (final int networkType : networkTypes) if (ConnectivityManager.isNetworkTypeValid(networkType)) { final NetworkInfo info = connectivity.getNetworkInfo(networkType); if (info.isAvailable() || info.isConnected() || info.isConnectedOrConnecting()) return true; }//from www . j a va 2 s .c o m return false; }
From source file:com.facebook.react.modules.netinfo.NetInfoModule.java
private String getCurrentConnectionType() { try {//from ww w . ja v a 2s . c om NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); if (networkInfo == null || !networkInfo.isConnected()) { return CONNECTION_TYPE_NONE; } else if (ConnectivityManager.isNetworkTypeValid(networkInfo.getType())) { return networkInfo.getTypeName().toUpperCase(); } else { return CONNECTION_TYPE_UNKNOWN; } } catch (SecurityException e) { mNoNetworkPermission = true; return CONNECTION_TYPE_UNKNOWN; } }