List of usage examples for android.net NetworkInfo isConnected
@Deprecated public boolean isConnected()
From source file:Main.java
public static boolean isConnected(Context context) { NetworkInfo net = getConnManager(context).getActiveNetworkInfo(); return net != null && net.isConnected(); }
From source file:Main.java
public static boolean isConnected(Context context) { if (context != null) { ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (conn != null) { NetworkInfo info = conn.getActiveNetworkInfo(); return (info != null && info.isConnected()); }/*from ww w. j a v a2s . c o m*/ } return false; }
From source file:Main.java
public static boolean isConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null && info.isConnected()) { if (info.getState() == NetworkInfo.State.CONNECTED) { return true; }/*from w w w . j a v a2 s .co m*/ } return false; }
From source file:Main.java
public static boolean isConnectedToWired(Context context) { ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); //ConnectivityManager.TYPE_ETHERNET == 9 , but only from API 13 NetworkInfo ethernet = connec.getNetworkInfo(9); if (ethernet != null && ethernet.isConnected()) { return true; } else {//from ww w . java2s. co m return false; } }
From source file:Main.java
public static boolean isConnected(Context context) { NetworkInfo info = getActiveNetworkInfo(context); return info != null && info.isConnected(); }
From source file:Main.java
public static boolean isNetConnect(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; } else {//w w w . ja v a2s . c o m return false; } }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { try {/*from w w w . ja v a 2 s. c om*/ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.isConnected()) { if (ni.getState() == NetworkInfo.State.CONNECTED) { return true; } } } } catch (Exception e) { return false; } return false; }
From source file:Main.java
public static boolean isConnect(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; } else {//from w w w . ja v a 2 s . c o m return false; } }
From source file:Main.java
public static boolean isNetConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getActiveNetworkInfo(); if (info != null && info.isConnected()) { return true; }/*from ww w . j ava 2 s. c o m*/ return false; }
From source file:Main.java
public static boolean isNetConnected() { ConnectivityManager connectivityManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getActiveNetworkInfo(); if (info != null && info.isConnected()) { return true; }//from w w w .jav a 2 s .co m return false; }