List of usage examples for android.net NetworkInfo isConnected
@Deprecated public boolean isConnected()
From source file:Main.java
public static boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); //should check null because in air plan mode it will be null return (netInfo != null && netInfo.isConnected()); }
From source file:Main.java
public static boolean isWifiAvailable(final Context context) { if (context != null) { final ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] connections = connManager.getAllNetworkInfo(); for (NetworkInfo netInfo : connections) { if (netInfo != null) { boolean connected = netInfo.isConnected(); int connectType = netInfo.getType(); if (connected) if (connectType == ConnectivityManager.TYPE_WIFI || connectType == ConnectivityManager.TYPE_ETHERNET) return true; }/*from w w w.j av a 2 s. c o m*/ } } return false; }
From source file:Main.java
public static boolean isWifiReady(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); String ssid = getWifiSSID(context); if (info.isConnected() && ssid != null && !"".equals(ssid)) { return true; } else {/*w ww . ja v a 2 s . co m*/ return false; } }
From source file:Main.java
public static boolean isMobileConnected(Context context) { NetworkInfo net = getConnectivityManager(context).getActiveNetworkInfo(); return net != null && net.getType() == ConnectivityManager.TYPE_MOBILE && net.isConnected(); }
From source file:Main.java
public static boolean isConnected(Context c) { NetworkInfo info = ((ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();/*from ww w. java2 s. com*/ return info != null && info.isConnected(); }
From source file:Main.java
public static boolean checkNetwork(Context context) { NetworkInfo networkinfo = ((ConnectivityManager) context.getSystemService("connectivity")) .getActiveNetworkInfo();/*w w w .ja v a2s.c om*/ return networkinfo != null && networkinfo.isConnected(); }
From source file:Main.java
/** * * @return/*from w w w . j a v a 2 s .com*/ */ public static boolean isWIFI(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (networkInfo != null) { return networkInfo.isConnected(); } return false; }
From source file:Main.java
public static boolean isNetworked(Context c) { // Check if we are on a network ConnectivityManager mManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo network = mManager.getActiveNetworkInfo(); if (network == null) { return false; }//ww w. j ava 2 s .co m if (network.isConnected()) { return true; } return false; // return (current.getState() == NetworkInfo.State.CONNECTED); }
From source file:Main.java
/** * Returns network availability status.//from w w w . ja v a2 s .c o m * @param context - Application context. * @return - Network availability status. */ public static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getActiveNetworkInfo(); if (info == null) { return false; } return info.isConnected(); }
From source file:Main.java
/** * * @return/*from w w w .j av a 2s . co m*/ */ public static boolean isMobile(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (networkInfo != null) { return networkInfo.isConnected(); } return false; }