当前位置: 首页>>代码示例>>Java>>正文


Java TelephonyManager.NETWORK_TYPE_HSPA属性代码示例

本文整理汇总了Java中android.telephony.TelephonyManager.NETWORK_TYPE_HSPA属性的典型用法代码示例。如果您正苦于以下问题:Java TelephonyManager.NETWORK_TYPE_HSPA属性的具体用法?Java TelephonyManager.NETWORK_TYPE_HSPA怎么用?Java TelephonyManager.NETWORK_TYPE_HSPA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.NETWORK_TYPE_HSPA属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNetworkType

/**
 * GPRS    2G(2.5) General Packet Radia Service 114kbps
 * EDGE    2G(2.75G) Enhanced Data Rate for GSM Evolution 384kbps
 * UMTS    3G WCDMA 联通3G Universal Mobile Telecommunication System 完整的3G移动通信技术标准
 * CDMA    2G 电信 Code Division Multiple Access 码分多址
 * EVDO_0  3G (EVDO 全程 CDMA2000 1xEV-DO) Evolution - Data Only (Data Optimized) 153.6kps - 2.4mbps 属于3G
 * EVDO_A  3G 1.8mbps - 3.1mbps 属于3G过渡,3.5G
 * 1xRTT   2G CDMA2000 1xRTT (RTT - 无线电传输技术) 144kbps 2G的过渡,
 * HSDPA   3.5G 高速下行分组接入 3.5G WCDMA High Speed Downlink Packet Access 14.4mbps
 * HSUPA   3.5G High Speed Uplink Packet Access 高速上行链路分组接入 1.4 - 5.8 mbps
 * HSPA    3G (分HSDPA,HSUPA) High Speed Packet Access
 * IDEN    2G Integrated Dispatch Enhanced Networks 集成数字增强型网络 (属于2G,来自维基百科)
 * EVDO_B  3G EV-DO Rev.B 14.7Mbps 下行 3.5G
 * LTE     4G Long Term Evolution FDD-LTE 和 TDD-LTE , 3G过渡,升级版 LTE Advanced 才是4G
 * EHRPD   3G CDMA2000向LTE 4G的中间产物 Evolved High Rate Packet Data HRPD的升级
 * HSPAP   3G HSPAP 比 HSDPA 快些
 *
 * @return {@link  NetWorkType}
 */
public static NetWorkType getNetworkType(Context context) {
    int type = getConnectedTypeINT(context);
    switch (type) {
        case ConnectivityManager.TYPE_WIFI:
            return NetWorkType.Wifi;
        case ConnectivityManager.TYPE_MOBILE:
        case ConnectivityManager.TYPE_MOBILE_DUN:
        case ConnectivityManager.TYPE_MOBILE_HIPRI:
        case ConnectivityManager.TYPE_MOBILE_MMS:
        case ConnectivityManager.TYPE_MOBILE_SUPL:
            int teleType = getTelephonyManager(context).getNetworkType();
            switch (teleType) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    return NetWorkType.Net2G;
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    return NetWorkType.Net3G;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    return NetWorkType.Net4G;
                default:
                    return NetWorkType.UnKnown;
            }
        default:
            return NetWorkType.UnKnown;
    }
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:56,代码来源:Network.java

示例2: getNetWorkType

/**
 * 获取当前的网络类型(WIFI,2G,3G,4G)
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
 *
 * @param context 上下文
 * @return 网络类型
 * <ul>
 * <li>{@link #NETWORK_WIFI   } = 1;</li>
 * <li>{@link #NETWORK_4G     } = 4;</li>
 * <li>{@link #NETWORK_3G     } = 3;</li>
 * <li>{@link #NETWORK_2G     } = 2;</li>
 * <li>{@link #NETWORK_UNKNOWN} = 5;</li>
 * <li>{@link #NETWORK_NO     } = -1;</li>
 * </ul>
 */
public static int getNetWorkType(Context context) {
    int netType = NETWORK_NO;
    NetworkInfo info = getActiveNetworkInfo(context);
    if (info != null && info.isAvailable()) {

        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            netType = NETWORK_WIFI;
        } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            switch (info.getSubtype()) {

                case NETWORK_TYPE_GSM:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    netType = NETWORK_2G;
                    break;

                case NETWORK_TYPE_TD_SCDMA:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    netType = NETWORK_3G;
                    break;

                case NETWORK_TYPE_IWLAN:
                case TelephonyManager.NETWORK_TYPE_LTE:
                    netType = NETWORK_4G;
                    break;
                default:

                    String subtypeName = info.getSubtypeName();
                    if (subtypeName.equalsIgnoreCase("TD-SCDMA")
                            || subtypeName.equalsIgnoreCase("WCDMA")
                            || subtypeName.equalsIgnoreCase("CDMA2000")) {
                        netType = NETWORK_3G;
                    } else {
                        netType = NETWORK_UNKNOWN;
                    }
                    break;
            }
        } else {
            netType = NETWORK_UNKNOWN;
        }
    }
    return netType;
}
 
开发者ID:zhongjuncoder,项目名称:AggregationNews,代码行数:69,代码来源:NetworkUtils.java

示例3: getConnectionString

/**
 * returns the type of the internet connection as string
 *
 * @param context
 * @return
 */
public static String getConnectionString(Context context) {
    NetworkInfo networkInfo = getNetworkInfo(context);
    if (networkInfo == null || !networkInfo.isConnected()) {
        return "offline";
    } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
        return "WIFI";
    } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
        int networkType = networkInfo.getSubtype();
        switch (networkType) {
            case TelephonyManager.NETWORK_TYPE_GPRS:
            case TelephonyManager.NETWORK_TYPE_EDGE:
            case TelephonyManager.NETWORK_TYPE_CDMA:
            case TelephonyManager.NETWORK_TYPE_1xRTT:
            case TelephonyManager.NETWORK_TYPE_IDEN: //api<8 : replace by 11
                return "2G";
            case TelephonyManager.NETWORK_TYPE_UMTS:
            case TelephonyManager.NETWORK_TYPE_EVDO_0:
            case TelephonyManager.NETWORK_TYPE_EVDO_A:
            case TelephonyManager.NETWORK_TYPE_HSDPA:
            case TelephonyManager.NETWORK_TYPE_HSUPA:
            case TelephonyManager.NETWORK_TYPE_HSPA:
            case TelephonyManager.NETWORK_TYPE_EVDO_B: //api<9 : replace by 14
            case TelephonyManager.NETWORK_TYPE_EHRPD:  //api<11 : replace by 12
            case TelephonyManager.NETWORK_TYPE_HSPAP:  //api<13 : replace by 15
                return "3G";
            case TelephonyManager.NETWORK_TYPE_LTE:    //api<11 : replace by 13
                return "4G";
            default:
                return "unknown";
        }
    } else {
        return "unknown";
    }
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:40,代码来源:HelperFunctions.java

示例4: getNetworkType

/**
 * 获取网络状态,wifi,wap,2g,3g,4g.
 *
 * @return int 网络状态 {@link #NETWORK_TYPE_2G},{@link #NETWORK_TYPE_3G},{@link #NETWORK_TYPE_4G}
 * {@link #NETWORK_TYPE_INVALID},{@link #NETWORK_TYPE_WAP},
 * {@link #NETWORK_TYPE_WIFI}
 */
public static int getNetworkType() {
    int strNetworkType = NETWORK_TYPE_INVALID;

    NetworkInfo networkInfo = ((ConnectivityManager) UtilManager.getContext().getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isConnected()) {
        if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
            strNetworkType = NETWORK_TYPE_WIFI;
        } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
            String _strSubTypeName = networkInfo.getSubtypeName();

            // TD-SCDMA   networkType is 17
            int networkType = networkInfo.getSubtype();
            switch (networkType) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN: //api<8 : replace by 11
                    strNetworkType = NETWORK_TYPE_2G;
                    break;
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B: //api<9 : replace by 14
                case TelephonyManager.NETWORK_TYPE_EHRPD:  //api<11 : replace by 12
                case TelephonyManager.NETWORK_TYPE_HSPAP:  //api<13 : replace by 15
                    strNetworkType = NETWORK_TYPE_3G;
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE:    //api<11 : replace by 13
                    strNetworkType = NETWORK_TYPE_4G;
                    break;
                default:
                    // http://baike.baidu.com/item/TD-SCDMA 中国移动 联通 电信 三种3G制式
                    if (_strSubTypeName.equalsIgnoreCase("TD-SCDMA") || _strSubTypeName.equalsIgnoreCase("WCDMA") || _strSubTypeName.equalsIgnoreCase("CDMA2000")) {
                        strNetworkType = NETWORK_TYPE_3G;
                    } else {
                        strNetworkType = NETWORK_TYPE_UNKNOWN;
                    }

                    break;
            }

        }
    }


    return strNetworkType;
}
 
开发者ID:sundevin,项目名称:utilsLibrary,代码行数:58,代码来源:NetworkUtils.java

示例5: getNetworkTypeForLink

public static int getNetworkTypeForLink(Context context) {
    try {
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getActiveNetworkInfo();
        if (ni != null) {
            if (ni.getType() == ConnectivityManager.TYPE_WIFI) {
                return LinkNetWorkType.WIFI;
            } else {
                if (ni.getType() == ConnectivityManager.TYPE_MOBILE) {
                    switch (ni.getSubtype()) {
                    case TelephonyManager.NETWORK_TYPE_GPRS:
                    case TelephonyManager.NETWORK_TYPE_EDGE:
                    case TelephonyManager.NETWORK_TYPE_CDMA:
                    case TelephonyManager.NETWORK_TYPE_1xRTT:
                    case TelephonyManager.NETWORK_TYPE_IDEN:
                        return LinkNetWorkType._2G;
                    case TelephonyManager.NETWORK_TYPE_UMTS:
                    case TelephonyManager.NETWORK_TYPE_EVDO_0:
                    case TelephonyManager.NETWORK_TYPE_EVDO_A:
                    case TelephonyManager.NETWORK_TYPE_HSDPA:
                    case TelephonyManager.NETWORK_TYPE_HSUPA:
                    case TelephonyManager.NETWORK_TYPE_HSPA:
                    case 12: // TelephonyManager.NETWORK_TYPE_EVDO_B:
                    case 14: // TelephonyManager.NETWORK_TYPE_EHRPD:
                    case 15: // TelephonyManager.NETWORK_TYPE_HSPAP:
                        return LinkNetWorkType._3G;
                    case 13: // TelephonyManager.NETWORK_TYPE_LTE:
                        return LinkNetWorkType._4G;
                    default:
                        return LinkNetWorkType._2G;
                    }
                }
            }
        }
    } catch (Exception e) {
        return LinkNetWorkType.UNKNOWN;
    }
    return LinkNetWorkType.UNKNOWN;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:39,代码来源:NetworkUtil.java

示例6: getNetworkTypeNameInMobile

private static String getNetworkTypeNameInMobile(int type) {
    switch (type) {
        case TelephonyManager.NETWORK_TYPE_GPRS:
            return "GPRS";
        case TelephonyManager.NETWORK_TYPE_EDGE:
            return "EDGE";
        case TelephonyManager.NETWORK_TYPE_UMTS:
            return "UMTS";
        case TelephonyManager.NETWORK_TYPE_HSDPA:
            return "HSDPA";
        case TelephonyManager.NETWORK_TYPE_HSUPA:
            return "HSUPA";
        case TelephonyManager.NETWORK_TYPE_HSPA:
            return "HSPA";
        case TelephonyManager.NETWORK_TYPE_CDMA:
            return "CDMA";
        case TelephonyManager.NETWORK_TYPE_EVDO_0:
            return "CDMA - EvDo rev. 0";
        case TelephonyManager.NETWORK_TYPE_EVDO_A:
            return "CDMA - EvDo rev. A";
        case TelephonyManager.NETWORK_TYPE_EVDO_B:
            return "CDMA - EvDo rev. B";
        case TelephonyManager.NETWORK_TYPE_1xRTT:
            return "CDMA - 1xRTT";
        case TelephonyManager.NETWORK_TYPE_LTE:
            return "LTE";
        case TelephonyManager.NETWORK_TYPE_EHRPD:
            return "CDMA - eHRPD";
        case TelephonyManager.NETWORK_TYPE_IDEN:
            return "iDEN";
        case TelephonyManager.NETWORK_TYPE_HSPAP:
            return "HSPA+";
        default:
            return "UNKNOWN";
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:36,代码来源:NetworkUtil.java

示例7: getNetworkSubType

/**
 * 获取当前网络具体类型
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
 *
 * @return 网络类型
 */
public static String getNetworkSubType(Context context) {
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = manager.getActiveNetworkInfo();
    String subtype = NETWORK_NO;

    if (info != null && info.isAvailable()) {
        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            subtype = NETWORK_WIFI;
        } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            switch (info.getSubtype()) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    subtype = getOperatorName(context).concat(NETWORK_2G);
                    break;
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    subtype = getOperatorName(context).concat(NETWORK_3G);
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    subtype = getOperatorName(context).concat(NETWORK_4G);
                    break;
                default:
                    String subtypeName = info.getSubtypeName();
                    if (subtypeName.equalsIgnoreCase("TD-SCDMA")
                            || subtypeName.equalsIgnoreCase("WCDMA")
                            || subtypeName.equalsIgnoreCase("CDMA2000")) {
                        subtype = getOperatorName(context).concat(NETWORK_3G);
                    } else {
                        subtype = NETWORK_UNKNOWN;
                    }
                    break;
            }
        } else {
            subtype = NETWORK_UNKNOWN;
        }
    }
    return subtype;
}
 
开发者ID:xiarunhao123,项目名称:Ency,代码行数:54,代码来源:AppNetWorkUtil.java

示例8: getNetworkType

/**
 * 获取自定义当前联网类型
 *
 * @return 网络类型。-1为网络不可用;0为未知网络;1为WIFI;2为2G;3为3G;4为4G
 */
public static int getNetworkType() {

    try {

        if (sContext != null) {

            ConnectivityManager connectivity = (ConnectivityManager) sContext
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            if (connectivity == null) {
                return Constants.NETWORK_TYPE_UNKNOWN;
            }

            NetworkInfo activeNetInfo = connectivity.getActiveNetworkInfo();
            if (activeNetInfo == null) {
                return Constants.NETWORK_TYPE_UNCONNECTED;
            }

            if (!activeNetInfo.isAvailable() || !activeNetInfo.isConnected()) {
                return Constants.NETWORK_TYPE_UNCONNECTED;
            }

            if (activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
                return Constants.NETWORK_TYPE_WIFI;

            } else if (activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) {

                switch (activeNetInfo.getSubtype()) {
                    case TelephonyManager.NETWORK_TYPE_CDMA:// ~ 14-64 kbps
                    case TelephonyManager.NETWORK_TYPE_IDEN:// ~25 kbps
                    case TelephonyManager.NETWORK_TYPE_1xRTT:// ~ 50-100 kbps
                    case TelephonyManager.NETWORK_TYPE_EDGE:// ~ 50-100 kbps
                    case TelephonyManager.NETWORK_TYPE_GPRS:// ~ 100 kbps
                        return Constants.NETWORK_TYPE_2G;

                    case TelephonyManager.NETWORK_TYPE_EVDO_0:// ~ 400-1000 kbps
                    case TelephonyManager.NETWORK_TYPE_UMTS:// ~ 400-7000 kbps
                    case TelephonyManager.NETWORK_TYPE_EVDO_A:// ~ 600-1400 kbps
                    case TelephonyManager.NETWORK_TYPE_HSPA:// ~ 700-1700 kbps
                    case TelephonyManager.NETWORK_TYPE_HSUPA:// ~ 1-23 Mbps
                    case TelephonyManager.NETWORK_TYPE_HSDPA:// ~ 2-14 Mbps
                    case 15: // 对应TelephonyManager.NETWORK_TYPE_HSPAP: 在api level
                        // 13下没有此值,但存在此网络类型,下面直接用数值代替
                        return Constants.NETWORK_TYPE_3G;

                    case 13: // 对应TelephonyManager.NETWORK_TYPE_LTE
                        return Constants.NETWORK_TYPE_4G;

                    case TelephonyManager.NETWORK_TYPE_UNKNOWN:
                    default:
                        return Constants.NETWORK_TYPE_UNKNOWN;
                }
            } else {
                return Constants.NETWORK_TYPE_UNKNOWN;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return Constants.NETWORK_TYPE_UNCONNECTED;
}
 
开发者ID:jonyChina162,项目名称:okhttpNDS,代码行数:66,代码来源:NetworkManager.java

示例9: isFastMobileNetwork

private static boolean isFastMobileNetwork(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);

    switch (telephonyManager.getNetworkType()) {
        case TelephonyManager.NETWORK_TYPE_1xRTT:
            return false; // ~ 50-100 kbps
        case TelephonyManager.NETWORK_TYPE_CDMA:
            return false; // ~ 14-64 kbps
        case TelephonyManager.NETWORK_TYPE_EDGE:
            return false; // ~ 50-100 kbps
        case TelephonyManager.NETWORK_TYPE_EVDO_0:
            return true; // ~ 400-1000 kbps
        case TelephonyManager.NETWORK_TYPE_EVDO_A:
            return true; // ~ 600-1400 kbps
        case TelephonyManager.NETWORK_TYPE_GPRS:
            return false; // ~ 100 kbps
        case TelephonyManager.NETWORK_TYPE_HSDPA:
            return true; // ~ 2-14 Mbps
        case TelephonyManager.NETWORK_TYPE_HSPA:
            return true; // ~ 700-1700 kbps
        case TelephonyManager.NETWORK_TYPE_HSUPA:
            return true; // ~ 1-23 Mbps
        case TelephonyManager.NETWORK_TYPE_UMTS:
            return true; // ~ 400-7000 kbps
        case TelephonyManager.NETWORK_TYPE_EHRPD:
            return true; // ~ 1-2 Mbps
        case TelephonyManager.NETWORK_TYPE_EVDO_B:
            return true; // ~ 5 Mbps
        case TelephonyManager.NETWORK_TYPE_HSPAP:
            return true; // ~ 10-20 Mbps
        case TelephonyManager.NETWORK_TYPE_IDEN:
            return false; // ~25 kbps
        case TelephonyManager.NETWORK_TYPE_LTE:
            return true; // ~ 10+ Mbps
        case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            return false;
        default:
            return false;

    }
}
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:42,代码来源:NetTypeUtils.java

示例10: isFastMobileNetwork

/**
 * Whether is fast mobile network
 * 
 * @param context
 * @return
 */
private static boolean isFastMobileNetwork(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null) {
        return false;
    }

    switch (telephonyManager.getNetworkType()) {
        case TelephonyManager.NETWORK_TYPE_1xRTT:
            return false;
        case TelephonyManager.NETWORK_TYPE_CDMA:
            return false;
        case TelephonyManager.NETWORK_TYPE_EDGE:
            return false;
        case TelephonyManager.NETWORK_TYPE_EVDO_0:
            return true;
        case TelephonyManager.NETWORK_TYPE_EVDO_A:
            return true;
        case TelephonyManager.NETWORK_TYPE_GPRS:
            return false;
        case TelephonyManager.NETWORK_TYPE_HSDPA:
            return true;
        case TelephonyManager.NETWORK_TYPE_HSPA:
            return true;
        case TelephonyManager.NETWORK_TYPE_HSUPA:
            return true;
        case TelephonyManager.NETWORK_TYPE_UMTS:
            return true;
        case TelephonyManager.NETWORK_TYPE_EHRPD:
            return true;
        case TelephonyManager.NETWORK_TYPE_EVDO_B:
            return true;
        case TelephonyManager.NETWORK_TYPE_HSPAP:
            return true;
        case TelephonyManager.NETWORK_TYPE_IDEN:
            return false;
        case TelephonyManager.NETWORK_TYPE_LTE:
            return true;
        case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            return false;
        default:
            return false;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:49,代码来源:NetWorkUtils.java

示例11: getCurrentConnectionSubtype

/**
 * Returns the connection subtype for the given NetworkState.
 */
public int getCurrentConnectionSubtype(NetworkState networkState) {
    if (!networkState.isConnected()) {
        return ConnectionSubtype.SUBTYPE_NONE;
    }

    switch (networkState.getNetworkType()) {
        case ConnectivityManager.TYPE_ETHERNET:
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_WIMAX:
        case ConnectivityManager.TYPE_BLUETOOTH:
            return ConnectionSubtype.SUBTYPE_UNKNOWN;
        case ConnectivityManager.TYPE_MOBILE:
            // Use information from TelephonyManager to classify the connection.
            switch (networkState.getNetworkSubType()) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                    return ConnectionSubtype.SUBTYPE_GPRS;
                case TelephonyManager.NETWORK_TYPE_EDGE:
                    return ConnectionSubtype.SUBTYPE_EDGE;
                case TelephonyManager.NETWORK_TYPE_CDMA:
                    return ConnectionSubtype.SUBTYPE_CDMA;
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                    return ConnectionSubtype.SUBTYPE_1XRTT;
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    return ConnectionSubtype.SUBTYPE_IDEN;
                case TelephonyManager.NETWORK_TYPE_UMTS:
                    return ConnectionSubtype.SUBTYPE_UMTS;
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                    return ConnectionSubtype.SUBTYPE_EVDO_REV_0;
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                    return ConnectionSubtype.SUBTYPE_EVDO_REV_A;
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                    return ConnectionSubtype.SUBTYPE_HSDPA;
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                    return ConnectionSubtype.SUBTYPE_HSUPA;
                case TelephonyManager.NETWORK_TYPE_HSPA:
                    return ConnectionSubtype.SUBTYPE_HSPA;
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                    return ConnectionSubtype.SUBTYPE_EVDO_REV_B;
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                    return ConnectionSubtype.SUBTYPE_EHRPD;
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    return ConnectionSubtype.SUBTYPE_HSPAP;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    return ConnectionSubtype.SUBTYPE_LTE;
                default:
                    return ConnectionSubtype.SUBTYPE_UNKNOWN;
            }
        default:
            return ConnectionSubtype.SUBTYPE_UNKNOWN;
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:54,代码来源:NetworkChangeNotifierAutoDetect.java

示例12: isConnectionFast

/**
  * Check if the connection is fast
  * @param type int
  * @param subType int
  * @return boolean
  */
 public static boolean isConnectionFast(int type, int subType) {
     if (type == ConnectivityManager.TYPE_WIFI) {
         return true;
     } else if (type == ConnectivityManager.TYPE_MOBILE) {
         switch(subType) {
             case TelephonyManager.NETWORK_TYPE_1xRTT:
                 return false; // ~ 50-100 kbps
             case TelephonyManager.NETWORK_TYPE_CDMA:
                 return false; // ~ 14-64 kbps
             case TelephonyManager.NETWORK_TYPE_EDGE:
                 return false; // ~ 50-100 kbps
             case TelephonyManager.NETWORK_TYPE_EVDO_0:
                 return true; // ~ 400-1000 kbps
             case TelephonyManager.NETWORK_TYPE_EVDO_A:
                 return true; // ~ 600-1400 kbps
             case TelephonyManager.NETWORK_TYPE_GPRS:
                 return false; // ~ 100 kbps
             case TelephonyManager.NETWORK_TYPE_HSDPA:
                 return true; // ~ 2-14 Mbps
             case TelephonyManager.NETWORK_TYPE_HSPA:
                 return true; // ~ 700-1700 kbps
             case TelephonyManager.NETWORK_TYPE_HSUPA:
                 return true; // ~ 1-23 Mbps
             case TelephonyManager.NETWORK_TYPE_UMTS:
                 return true; // ~ 400-7000 kbps
/*
 * Above API level 7, make sure to set android:targetSdkVersion
 * to appropriate level to use these
 */
             case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11
                 return true; // ~ 1-2 Mbps
             case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9
                 return true; // ~ 5 Mbps
             case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13
                 return true; // ~ 10-20 Mbps
             case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8
                 return false; // ~25 kbps
             case TelephonyManager.NETWORK_TYPE_LTE: // API level 11
                 return true; // ~ 10+ Mbps
             // Unknown
             case TelephonyManager.NETWORK_TYPE_UNKNOWN:
             default:
                 return false;
         }
     } else {
         return false;
     }
 }
 
开发者ID:sfilmak,项目名称:MakiLite,代码行数:54,代码来源:Connectivity.java

示例13: isFastMobileNetwork

/**
 * Do you have a fast mobile network?
 *
 * @param context context
 * @return Do you have a fast mobile network? [boolean]
 */
private static boolean isFastMobileNetwork(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null) return false;
    switch (telephonyManager.getNetworkType()) {
        case TelephonyManager.NETWORK_TYPE_1xRTT:
            return false;
        case TelephonyManager.NETWORK_TYPE_CDMA:
            return false;
        case TelephonyManager.NETWORK_TYPE_EDGE:
            return false;
        case TelephonyManager.NETWORK_TYPE_EVDO_0:
            return true;
        case TelephonyManager.NETWORK_TYPE_EVDO_A:
            return true;
        case TelephonyManager.NETWORK_TYPE_GPRS:
            return false;
        case TelephonyManager.NETWORK_TYPE_HSDPA:
            return true;
        case TelephonyManager.NETWORK_TYPE_HSPA:
            return true;
        case TelephonyManager.NETWORK_TYPE_HSUPA:
            return true;
        case TelephonyManager.NETWORK_TYPE_UMTS:
            return true;
        case TelephonyManager.NETWORK_TYPE_EHRPD:
            return true;
        case TelephonyManager.NETWORK_TYPE_EVDO_B:
            return true;
        case TelephonyManager.NETWORK_TYPE_HSPAP:
            return true;
        case TelephonyManager.NETWORK_TYPE_IDEN:
            return false;
        case TelephonyManager.NETWORK_TYPE_LTE:
            return true;
        case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            return false;
        default:
            return false;
    }
}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:46,代码来源:NetworkUtils.java

示例14: isConnectionFast

/**
 * Check if the connection is fast
 *
 * @param type
 * @param subType
 * @return
 */
public static boolean isConnectionFast(int type, int subType) {
    if (type == ConnectivityManager.TYPE_WIFI) {
        return true;
    } else if (type == ConnectivityManager.TYPE_MOBILE) {
        switch (subType) {
            case TelephonyManager.NETWORK_TYPE_1xRTT:
                return false; // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_CDMA:
                return false; // ~ 14-64 kbps
            case TelephonyManager.NETWORK_TYPE_EDGE:
                return false; // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_0:
                return true; // ~ 400-1000 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_A:
                return true; // ~ 600-1400 kbps
            case TelephonyManager.NETWORK_TYPE_GPRS:
                return false; // ~ 100 kbps
            case TelephonyManager.NETWORK_TYPE_HSDPA:
                return true; // ~ 2-14 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPA:
                return true; // ~ 700-1700 kbps
            case TelephonyManager.NETWORK_TYPE_HSUPA:
                return true; // ~ 1-23 Mbps
            case TelephonyManager.NETWORK_TYPE_UMTS:
                return true; // ~ 400-7000 kbps
        /*
         * Above API level 7, make sure to set android:targetSdkVersion
* to appropriate level to use these
*/
            case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11
                return true; // ~ 1-2 Mbps
            case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9
                return true; // ~ 5 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13
                return true; // ~ 10-20 Mbps
            case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8
                return false; // ~25 kbps
            case TelephonyManager.NETWORK_TYPE_LTE: // API level 11
                return true; // ~ 10+ Mbps
            // Unknown
            case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            default:
                return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:55,代码来源:Connectivity.java

示例15: getNetworkType

private String getNetworkType() {

        NetworkInfo info = ((ConnectivityManager) mNeihanPreference.getContext().getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
        if (info != null && info.isAvailable()) {
            if (info.getType() == ConnectivityManager.TYPE_WIFI) {
                return "wifi";
            } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
                switch (info.getSubtype()) {
                    case TelephonyManager.NETWORK_TYPE_GSM:
                    case TelephonyManager.NETWORK_TYPE_GPRS:
                    case TelephonyManager.NETWORK_TYPE_CDMA:
                    case TelephonyManager.NETWORK_TYPE_EDGE:
                    case TelephonyManager.NETWORK_TYPE_1xRTT:
                    case TelephonyManager.NETWORK_TYPE_IDEN:
                        return "2g";
                    case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
                    case TelephonyManager.NETWORK_TYPE_EVDO_A:
                    case TelephonyManager.NETWORK_TYPE_UMTS:
                    case TelephonyManager.NETWORK_TYPE_EVDO_0:
                    case TelephonyManager.NETWORK_TYPE_HSDPA:
                    case TelephonyManager.NETWORK_TYPE_HSUPA:
                    case TelephonyManager.NETWORK_TYPE_HSPA:
                    case TelephonyManager.NETWORK_TYPE_EVDO_B:
                    case TelephonyManager.NETWORK_TYPE_EHRPD:
                    case TelephonyManager.NETWORK_TYPE_HSPAP:
                        return "3g";
                    case TelephonyManager.NETWORK_TYPE_IWLAN:
                    case TelephonyManager.NETWORK_TYPE_LTE:
                        return "4g";
                    default:
                        String subtypeName = info.getSubtypeName();
                        if (subtypeName.equalsIgnoreCase("TD-SCDMA")
                                || subtypeName.equalsIgnoreCase("WCDMA")
                                || subtypeName.equalsIgnoreCase("CDMA2000")) {
                            return "3g";
                        } else {
                            return "wifi";
                        }
                }
            } else {
                return "wifi";
            }
        }
        return "wifi";
    }
 
开发者ID:crazysunj,项目名称:CrazyDaily,代码行数:45,代码来源:NeihanManager.java


注:本文中的android.telephony.TelephonyManager.NETWORK_TYPE_HSPA属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。