List of usage examples for android.net NetworkInfo isAvailable
@Deprecated public boolean isAvailable()
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isAvailable(); }
From source file:Main.java
public static boolean hasNetwork(Context context) { ConnectivityManager con = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo workinfo = con.getActiveNetworkInfo(); if (workinfo == null || !workinfo.isAvailable()) { return false; } else {//w w w . j av a 2s . c om return true; } }
From source file:Main.java
public static boolean checkNetworkInfo(Context context) { ConnectivityManager conMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkinfo = conMan.getActiveNetworkInfo(); return networkinfo != null && networkinfo.isAvailable(); }
From source file:Main.java
public static boolean isNetWorkdetect(Context context) { ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkinfo = conn.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; }/*from ww w.j a va2s. com*/ return true; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkINfo = cm.getActiveNetworkInfo(); if (networkINfo != null && networkINfo.isAvailable() && networkINfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; }//from w ww . java 2 s.co m return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; }// w ww . j a v a 2 s.c o m return true; }
From source file:Main.java
public static boolean checkWifiConnection(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifi.isAvailable()) return true; else// w w w.j a va2 s . c om return false; }
From source file:Main.java
public static boolean isOnWifiInternet(Context context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return (info.isAvailable() && info.isConnected()); }
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 w w w . j a va 2 s .c o m return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { NetworkInfo info = getNetworkInfo(context); if (info != null) { return info.isAvailable(); }//from w w w . j a v a2 s.co m return false; }