List of usage examples for android.net ConnectivityManager getActiveNetworkInfo
@Deprecated
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
@Nullable
public NetworkInfo getActiveNetworkInfo()
From source file:Main.java
public static boolean isNetworkAvailable(Context c) { ConnectivityManager connectivityManager = (ConnectivityManager) c .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null; }
From source file:Main.java
@SuppressLint("DefaultLocale") public static boolean isCMWap(Context context) { boolean res = false; ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo == null) { return res; }//from w w w .ja v a 2s .c o m int nType = networkInfo.getType(); String eInfo = networkInfo.getExtraInfo(); if (nType == ConnectivityManager.TYPE_MOBILE && eInfo != null) { if (eInfo.toLowerCase().equals("cmwap")) { res = true; } } return res; }
From source file:Main.java
public static boolean networkCanUse(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netinfo = connectivityManager.getActiveNetworkInfo(); if (netinfo != null && netinfo.isConnected()) { return true; }//from w ww . ja v a 2 s . c om return false; }
From source file:Main.java
public static boolean hasInternet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return info != null && info.isAvailable() && info.isConnected(); }
From source file:Main.java
public static boolean isConnectInternet(Context context) { ConnectivityManager conManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = conManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isConnectedOrConnecting(); }//from www . j av a2 s . com return false; }
From source file:Main.java
/** * test if there is some connection//from w w w .j a v a 2s . c om * @param ctx * @return */ public static boolean verifyConnectivity(Context ctx) { ConnectivityManager connectivityManager = (ConnectivityManager) ctx .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnectedOrConnecting(); }
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; }/* w ww. j a va 2 s . c o m*/ return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { try {//from w ww . j av a2 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 isNetworkAvailable(Context c) { ConnectivityManager connectivityManager = (ConnectivityManager) c .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
From source file:Main.java
public static boolean isNetWorkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); }