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 isHighBandwidthConnection(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return (info != null && info.isConnected() && isConnectionFast(info.getType(), info.getSubtype())); }
From source file:Main.java
public static boolean isNetworked(Context c) { // Check if we are on a network ConnectivityManager mManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo current = mManager.getActiveNetworkInfo(); if (current == null) { return false; }// w w w . ja v a2 s . c om return (current.getState() == NetworkInfo.State.CONNECTED); }
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 checkInternet(Activity act) { ConnectivityManager conMgr = (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo i = conMgr.getActiveNetworkInfo(); if (i == null) { return false; }//from w w w. j a v a 2 s. c o m if (!i.isConnected()) { return false; } if (!i.isAvailable()) { return false; } return true; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); return cm != null && cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static Boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnectedOrConnecting()) return true; return false; }
From source file:Main.java
public static boolean checkNetwork(Context context) { ConnectivityManager netManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = netManager.getActiveNetworkInfo(); if (info != null) return info.isAvailable(); else//from w w w . j av a 2s .c o m return false; }
From source file:Main.java
public static boolean isConnected(Context context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connManager.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); }
From source file:Main.java
public static boolean isNetWorkInfoNull(Context context) { ConnectivityManager conManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = conManager.getActiveNetworkInfo(); return networkInfo == null ? true : false; }
From source file:Main.java
public static boolean networkConnected(Activity activity) { ConnectivityManager conManager = (ConnectivityManager) activity .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = conManager.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); }