List of usage examples for android.net NetworkInfo isConnected
@Deprecated public boolean isConnected()
From source file:Main.java
public static boolean isInternetAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnected()) { return true; }// w ww . j ava2s.co m return false; }
From source file:Main.java
/** * Check if there is any connectivity to a Wifi network. * <p/>// w ww . j av a 2s . c om * Can be used in combination with {@link #isConnectedMobile} * to provide different features if the device is on a wifi network or a cell network. * * @param context The current Context or Activity that this method is called from * @return true if a wifi connection is available, otherwise false. */ public static boolean isConnectedWifi(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return (info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI); }
From source file:Main.java
public static boolean verifyConnection(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnected()) { return true; } else {//from ww w .j a v a 2s . c om return false; } }
From source file:Main.java
public static boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnected()) { return true; }//w w w .j a v a 2 s . com return false; }
From source file:Main.java
public static boolean isOnline(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Activity.CONNECTIVITY_SERVICE); NetworkInfo info = manager.getActiveNetworkInfo(); if (info != null && info.isConnected()) { return true; }//w w w .ja va 2s.c o m return false; }
From source file:Main.java
/** * @param context/* w w w . j a v a2 s . c o m*/ * @return */ public static final boolean isNetworkAvailable(final Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnected(); }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { try {// w w w.j a v a 2 s . c o m ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return null != info && info.isConnected(); } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
static boolean isNetworkAvailable(Context context) { try {/* w ww . ja v a2s .c om*/ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return null != info && info.isConnected(); } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static boolean isNetWorkConnected(Context context) { boolean result; ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); result = netInfo != null && netInfo.isConnected(); return result; }
From source file:Main.java
public static boolean isNetworkAvailable(@Nonnull Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); }