List of usage examples for android.net NetworkInfo isConnected
@Deprecated public boolean isConnected()
From source file:Main.java
public static boolean isAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; }/*w w w . j a va 2s. c o m*/ return false; }
From source file:Main.java
public static boolean isOnline(ConnectivityManager connMgr) { NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null && networkInfo.isConnected()); }
From source file:Main.java
public static boolean hasNetwork(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) return false; NetworkInfo[] networkInfos = connectivityManager.getAllNetworkInfo(); for (NetworkInfo networkInfo : networkInfos) { if (networkInfo != null && networkInfo.isConnected()) return true; }/* w ww . ja va2 s .com*/ return false; }
From source file:Main.java
public static boolean isNetworkActivate(Context context) { boolean isConnected = false; ConnectivityManager cgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cgr == null) { return false; }//from w ww. j av a 2 s.c o m NetworkInfo info = cgr.getActiveNetworkInfo(); if ((info != null) && info.isConnected()) { isConnected = true; } return isConnected; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = connec.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnected() == true) { return true; }/*from www . j a v a2 s . c om*/ return false; }
From source file:Main.java
public static boolean isAnyNetworkConnected(final Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); }
From source file:Main.java
/** Returns true if an internet connection is available. */ public static boolean isInternetAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); }
From source file:Main.java
public static boolean isConnected(Context mContext) { ConnectivityManager connectivityManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) { return false; }// w w w. ja v a2 s . co m NetworkInfo[] networkInfoList = connectivityManager.getAllNetworkInfo(); if (networkInfoList != null) { for (NetworkInfo nwInfo : networkInfoList) { if (nwInfo.isConnected()) { return true; } } } return false; }
From source file:Main.java
public static boolean isOnline(Context context) { ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null && networkInfo.isConnected()); }
From source file:Main.java
public static boolean isConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (null == cm) { return false; }/*from www . j a v a 2s. com*/ NetworkInfo info = cm.getActiveNetworkInfo(); if (null != info && info.isConnected()) { if (info.getState() == NetworkInfo.State.CONNECTED) { return true; } } return false; }