Example usage for android.net NetworkInfo getSubtype

List of usage examples for android.net NetworkInfo getSubtype

Introduction

In this page you can find the example usage for android.net NetworkInfo getSubtype.

Prototype

@Deprecated
public int getSubtype() 

Source Link

Document

Return a network-type-specific integer describing the subtype of the network.

Usage

From source file:Main.java

protected static int getMoblieNetType(Context context) {
    ConnectivityManager connectMgr = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = connectMgr.getActiveNetworkInfo();
    return info.getSubtype();
}

From source file:Main.java

/**
 * is2G//from   w w  w. j  av a  2s .c  o  m
 * @param context
 * @return boolean
 */
public static boolean is2G(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
    if (activeNetInfo != null && (activeNetInfo.getSubtype() == TelephonyManager.NETWORK_TYPE_EDGE
            || activeNetInfo.getSubtype() == TelephonyManager.NETWORK_TYPE_GPRS
            || activeNetInfo.getSubtype() == TelephonyManager.NETWORK_TYPE_CDMA)) {
        return true;
    }
    return false;
}

From source file:Main.java

public static boolean is4G(Context context) {
    NetworkInfo info = getActiveNetworkInfo(context);
    return info != null && info.isAvailable() && info.getSubtype() == TelephonyManager.NETWORK_TYPE_LTE;
}

From source file:Main.java

public static boolean checkWifiNetwork(Context context) {
    boolean has = false;
    ConnectivityManager connectivity = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = connectivity.getActiveNetworkInfo();
    int netType = info.getType();
    int netSubtype = info.getSubtype();
    if (netType == ConnectivityManager.TYPE_WIFI) {
        has = info.isConnected();//  w  w  w .j  ava 2 s  .  c  om
    }
    return has;
}

From source file:Main.java

public static int isHightBandwidthConnection(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();
    return isConnectionFast(info.getType(), info.getSubtype());
}

From source file:Main.java

public static boolean checkGprsNetwork(Context context) {
    boolean has = false;
    ConnectivityManager connectivity = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    NetworkInfo info = connectivity.getActiveNetworkInfo();
    int netType = info.getType();
    int netSubtype = info.getSubtype();
    if (netType == ConnectivityManager.TYPE_MOBILE && netSubtype == TelephonyManager.NETWORK_TYPE_UMTS
            && !mTelephony.isNetworkRoaming()) {
        has = info.isConnected();/*from www  .  ja va 2  s  .  c o  m*/
    }
    return has;

}

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 isWifiOr3G(Context ctx) {
    ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();
    if (info == null)
        return false;

    int netType = info.getType();
    int netSubtype = info.getSubtype();
    if (netType == ConnectivityManager.TYPE_WIFI) {
        return info.isConnected();
    } else if (netType == ConnectivityManager.TYPE_MOBILE && netSubtype == TelephonyManager.NETWORK_TYPE_UMTS) {
        return info.isConnected();
    } else {/*w w  w .j  ava 2 s  .c  o m*/
        return false;
    }
}

From source file:Main.java

public static int getCurrentNetworkSubtype(Context context) {
    NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE))
            .getActiveNetworkInfo();/*from   w ww.  j  a v a2s .c  o m*/
    return networkInfo != null ? networkInfo.getSubtype() : -1231545315;
}

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()));
}