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 String getNetworkInfo(Context act) { ConnectivityManager cm = (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) return null; NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) return info.toString(); return null;/*ww w . j av a2 s .c o m*/ }
From source file:Main.java
public static Boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
From source file:Main.java
public static boolean isNetConnected(Context context) { if (context != null) { final ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = cm.getActiveNetworkInfo(); return !(networkInfo == null || !networkInfo.isConnectedOrConnecting()); } else {/*from w w w . ja v a2 s . c om*/ return false; } }
From source file:Main.java
@Deprecated public static boolean isWifi(Context mContext) { ConnectivityManager connectivityManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; }// w w w. j a va2 s . c o m return false; }
From source file:Main.java
public static boolean isWIFI(Context context) { try {/* w w w . j a v a 2s .com*/ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI) { return true; } } } catch (Exception e) { return false; } return false; }
From source file:Main.java
public static boolean is3G(Context context) { try {/*from www . j av a 2s. c om*/ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.getType() == ConnectivityManager.TYPE_MOBILE) { return true; } } } catch (Exception e) { } return false; }
From source file:Main.java
/** * /*from www . j a v a2 s.co m*/ * @return */ public static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
From source file:Main.java
public static boolean isNetworkConnected(Context context) { if (context != null) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isAvailable(); }//from ww w.ja v a2s . co m } return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { if (context == null) return false; ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
From source file:Main.java
/** * Determine the network connection/* w w w . j a v a 2 s . com*/ * * @param context * the Context * @return TRUE if network connect is establishing */ public static boolean isConnect(Context context) { // Checking network configuration ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnectedOrConnecting(); }