List of usage examples for android.net NetworkInfo isAvailable
@Deprecated public boolean isAvailable()
From source file:Main.java
public static boolean isInternetConnected(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; }//from w w w.j av a2 s . co m return true; }
From source file:Main.java
public static boolean getNetStatus(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; }/*from ww w . ja v a 2s .c o m*/ return true; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { try {/* w w w . ja v a 2 s . c o m*/ ConnectivityManager manager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = manager.getActiveNetworkInfo(); return (info != null && info.isAvailable()); } catch (Exception e) { // ignore } return false; }
From source file:Main.java
public static boolean isNetWorkAvilable(final Context context) { final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = cm.getActiveNetworkInfo(); return networkInfo == null || !networkInfo.isAvailable(); }
From source file:Main.java
public static boolean checkNet(Context paramContext) { ConnectivityManager manager = (ConnectivityManager) paramContext.getSystemService("connectivity"); NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; }// w ww .j a va 2 s .com return true; }
From source file:Main.java
public static boolean hasActiveNetwork(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) { return info.isAvailable(); }//from w w w . j a va2 s . com return false; }
From source file:Main.java
public static boolean isNetworkAvaliable(Context context) { ConnectivityManager manager = (ConnectivityManager) (context .getSystemService(Context.CONNECTIVITY_SERVICE)); NetworkInfo networkinfo = manager.getActiveNetworkInfo(); return !(networkinfo == null || !networkinfo.isAvailable()); }
From source file:Main.java
public static boolean has(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) { return false; }//from w w w . j a v a 2 s . c om NetworkInfo info = connectivityManager.getActiveNetworkInfo(); return (info != null) && info.isAvailable(); }
From source file:Main.java
public static boolean isNetworkAvailable(Context ctx) { NetworkInfo nki = getCurrentNetStatus(ctx); if (nki != null) { return nki.isAvailable(); } else {//from w w w. j a v a 2 s. c o m return false; } }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { if (context == null) { Log.e("isNetworkAvailable", " Context is null"); return false; }/*from ww w . j a va2s.c om*/ try { ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null) { NetworkInfo info = connectivity.getActiveNetworkInfo(); return info.isAvailable(); } } catch (Exception e) { return false; } return false; }