List of usage examples for android.net NetworkInfo isConnectedOrConnecting
@Deprecated public boolean isConnectedOrConnecting()
From source file:Main.java
public static boolean isConnectedOrConnecting(Context context) { NetworkInfo[] nets = getConnectivityManager(context).getAllNetworkInfo(); if (nets != null) { for (NetworkInfo net : nets) { if (net.isConnectedOrConnecting()) { return true; }/* w ww. j a va 2 s .c o m*/ } } return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean hasInternetConnection(final Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isOnWIFI(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnectedOrConnecting() && ni.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static boolean isConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isNetworkConnected(Context ct) { ConnectivityManager cm = (ConnectivityManager) ct.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isNetworkConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { if (context == null) { return false; }/*from w w w . j a v a 2 s . c o m*/ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isConnectedOrConnecting(Context context) { NetworkInfo[] nets = getConnManager(context).getAllNetworkInfo(); if (nets != null) { NetworkInfo[] networkInfos = nets; int length = nets.length; for (int i = 0; i < length; ++i) { NetworkInfo net = networkInfos[i]; if (net.isConnectedOrConnecting()) { return true; }/*from w ww . jav a 2 s .c o m*/ } } return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return (netInfo != null && netInfo.isConnectedOrConnecting()); }