List of usage examples for android.net NetworkInfo getType
@Deprecated public int getType()
From source file:Main.java
public static boolean isHightBandwidthConnection(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 int getCurrentNetworkType(Context context) { NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();//w ww.j a v a 2s . c o m return networkInfo != null ? networkInfo.getType() : -1231545315; }
From source file:Main.java
public static boolean is4G(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null && activeNetInfo.isConnectedOrConnecting()) { if (activeNetInfo.getType() == TelephonyManager.NETWORK_TYPE_LTE) { return true; }// w w w .ja v a 2 s. c o m } return false; }
From source file:Main.java
public static boolean isWiFi(Context context) { NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();// ww w. j a v a2 s .c om return (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI); }
From source file:Main.java
public static boolean isMobileNetwork(Context context) { NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();//from w w w. j a v a 2 s. com return (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_MOBILE); }
From source file:Main.java
public static int getConnectedType(Context context) { if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); if (mNetworkInfo != null && mNetworkInfo.isAvailable()) { return mNetworkInfo.getType(); }/*from ww w . j a va 2s . c om*/ } return -1; }
From source file:Main.java
static private int getNetType(Context context) { ConnectivityManager mConnectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = mConnectivity.getActiveNetworkInfo(); if (info == null) { //no connection at all return NO_CONNECTIVITY; }/*from www . j a v a 2 s . c o m*/ return info.getType(); }
From source file:Main.java
public static boolean isWapNet(Context context) { ConnectivityManager conManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = conManager.getActiveNetworkInfo(); if (info != null && info.isAvailable()) { if (info.getType() == 1) { return false; } else {/*from w ww.j a v a 2s. co m*/ String currentAPN = info.getExtraInfo(); return !TextUtils.isEmpty(currentAPN) && (currentAPN.equals("cmwap") || currentAPN.equals("uniwap") || currentAPN.equals("3gwap")); } } else { return false; } }
From source file:Main.java
public static String getNetworkType(ConnectivityManager connManager) { NetworkInfo networkInfo = connManager.getActiveNetworkInfo(); String networkType = null;//from w w w . j a v a 2 s . co m if (networkInfo == null) { networkType = "not connect"; } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { networkType = "wifi"; } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { networkType = "mobile"; } return networkType; }
From source file:Main.java
public static boolean checkConnection(Context context, boolean onlyWiFi) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); boolean isWiFi = activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_WIFI; if (!onlyWiFi) { return isConnected; } else {//from w w w.j av a 2 s. c o m return isConnected && isWiFi; } }