當前位置: 首頁>>代碼示例>>Java>>正文


Java TelephonyManager.NETWORK_TYPE_EHRPD屬性代碼示例

本文整理匯總了Java中android.telephony.TelephonyManager.NETWORK_TYPE_EHRPD屬性的典型用法代碼示例。如果您正苦於以下問題:Java TelephonyManager.NETWORK_TYPE_EHRPD屬性的具體用法?Java TelephonyManager.NETWORK_TYPE_EHRPD怎麽用?Java TelephonyManager.NETWORK_TYPE_EHRPD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.NETWORK_TYPE_EHRPD屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isFastMobileNetwork

/**
 * 通過TelephonyManager服務獲取網絡連接的網速類別
 * @param context
 * @return
 */
public 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:ymqq,項目名稱:CommonFramework,代碼行數:44,代碼來源:NetworkStatusUtils.java

示例2: Only

/**
 * 判斷當前網絡是否是3G網絡  
 *
 GPRS       2G(2.5) General Packet Radia Service 114kbps
 EDGE       2G(2.75G) Enhanced Data Rate for GSM Evolution 384kbps

 CDMA     2G 電信 Code Division Multiple Access 碼分多址
 1xRTT      2G CDMA2000 1xRTT (RTT - 無線電傳輸技術) 144kbps 2G的過渡,
 IDEN      2G Integrated Dispatch Enhanced Networks 集成數字增強型網絡 (屬於2G,來自維基百科)

 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
 UMTS      3G WCDMA 聯通3G Universal Mobile Telecommunication System 完整的3G移動通信技術標準
 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
 EVDO_B 3G EV-DO Rev.B 14.7Mbps 下行 3.5G
 EHRPD  3G CDMA2000向LTE 4G的中間產物 Evolved High Rate Packet Data HRPD的升級
 HSPAP  3G HSPAP 比 HSDPA 快些

 LTE        4G Long Term Evolution FDD-LTE 和 TDD-LTE , 3G過渡,升級版 LTE Advanced 才是4G

 * @param context
 * @return boolean
 */
public static boolean is3G(Context context) {
	TelephonyManager telephoneManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
	final int type = telephoneManager.getNetworkType();
	//聯通3g
	if (type == TelephonyManager.NETWORK_TYPE_UMTS
			|| type == TelephonyManager.NETWORK_TYPE_HSDPA
			||type == TelephonyManager.NETWORK_TYPE_HSUPA) {
		return true;
	}
	//電信3g
	else if (type== TelephonyManager.NETWORK_TYPE_EVDO_0
			||type== TelephonyManager.NETWORK_TYPE_EVDO_A) {
		return true;
	}
	//其他3g網絡
	else if ( type == TelephonyManager.NETWORK_TYPE_HSPA
			||type== TelephonyManager.NETWORK_TYPE_EVDO_B
			||type== TelephonyManager.NETWORK_TYPE_EHRPD
			||type== TelephonyManager.NETWORK_TYPE_HSPAP) {
		return true;
	}
	//4g網絡
	else	if (type == TelephonyManager.NETWORK_TYPE_LTE) {
		return true;
	}
	return false;
}
 
開發者ID:ebridfighter,項目名稱:GongXianSheng,代碼行數:53,代碼來源:CommonUtils.java

示例3: 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

示例4: 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:weiwenqiang,項目名稱:GitHub,代碼行數:70,代碼來源:NetworkUtils.java

示例5: 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

示例6: getNetworkType

/**
 * 獲取當前網絡類型
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
 *
 * @param context 上下文
 * @return 網絡類型
 * <ul>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_WIFI   } </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_4G     } </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_3G     } </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_2G     } </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_UNKNOWN} </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_NO     } </li>
 * </ul>
 */
public static NetworkType getNetworkType(Context context) {
    NetworkType netType = NetworkType.NETWORK_NO;
    NetworkInfo info = getActiveNetworkInfo(context);
    if (info != null && info.isAvailable()) {

        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            netType = NetworkType.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 = NetworkType.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 = NetworkType.NETWORK_3G;
                    break;

                case NETWORK_TYPE_IWLAN:
                case TelephonyManager.NETWORK_TYPE_LTE:
                    netType = NetworkType.NETWORK_4G;
                    break;
                default:
                    String subtypeName = info.getSubtypeName();
                    if ("TD-SCDMA".equalsIgnoreCase(subtypeName) ||
                            "WCDMA".equalsIgnoreCase(subtypeName) ||
                            "CDMA2000".equalsIgnoreCase(subtypeName)) {
                        netType = NetworkType.NETWORK_3G;
                    } else {
                        netType = NetworkType.NETWORK_UNKNOWN;
                    }
                    break;
            }
        } else {
            netType = NetworkType.NETWORK_UNKNOWN;
        }
    }
    return netType;
}
 
開發者ID:imliujun,項目名稱:LJFramework,代碼行數:68,代碼來源:NetworkUtils.java

示例7: 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:newDeepLearing,項目名稱:decoy,代碼行數:36,代碼來源:NetworkUtil.java

示例8: getNetworkType

public static NetworkType getNetworkType(NetworkInfo info) {
    NetworkType netType = NetworkType.NETWORK_NO;
    if (info != null && info.isAvailable()) {

        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            netType = NetworkType.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 = NetworkType.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 = NetworkType.NETWORK_3G;
                    break;

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

                    String subtypeName = info.getSubtypeName();
                    if (subtypeName.equalsIgnoreCase("TD-SCDMA")
                            || subtypeName.equalsIgnoreCase("WCDMA")
                            || subtypeName.equalsIgnoreCase("CDMA2000")) {
                        netType = NetworkType.NETWORK_3G;
                    } else {
                        netType = NetworkType.NETWORK_UNKNOWN;
                    }
                    break;
            }
        } else {
            netType = NetworkType.NETWORK_UNKNOWN;
        }
    }
    return netType;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:53,代碼來源:NetworkUtils.java

示例9: getNetworkType

/**
 * 獲取手機連接的網絡類型(2G,3G,4G)
 * <p>聯通的3G為UMTS或HSDPA,移動和聯通的2G為GPRS或EGDE,電信的2G為CDMA,電信的3G為EVDO
 */
public static int getNetworkType(Context context) {
    TelephonyManager tm = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    switch (tm.getNetworkType()) {
        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 Constants.NETWORK_CLASS_2_G;
        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 Constants.NETWORK_CLASS_3_G;
        case TelephonyManager.NETWORK_TYPE_LTE:
            return Constants.NETWORK_CLASS_4_G;
        default:
            return Constants.NETWORK_CLASS_UNKNOWN;
    }
}
 
開發者ID:zhuangzaiku,項目名稱:AndroidCollection,代碼行數:30,代碼來源:NetworkUtils.java

示例10: getNetType

/**
 * 判斷手機連接的網絡類型(wifi,2G,3G,4G)
 * 聯通的3G為UMTS或HSDPA,移動和聯通的2G為GPRS或EGDE,電信的2G為CDMA,電信的3G為EVDO
 */
public static int getNetType(Context context) {
    int netWorkType = NETWORK_CLASS_UNKNOWN;
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isConnected()) {
        int type = networkInfo.getType();
        if (type == ConnectivityManager.TYPE_WIFI) {
            netWorkType = NETWORK_WIFI;
        } else if (type == ConnectivityManager.TYPE_MOBILE) {
            TelephonyManager telephonyManager = (TelephonyManager) context
                    .getSystemService(Context.TELEPHONY_SERVICE);
            switch (telephonyManager.getNetworkType()) {
                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 NETWORK_CLASS_2_G;
                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 NETWORK_CLASS_3_G;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    return NETWORK_CLASS_4_G;
                default:
                    return NETWORK_CLASS_UNKNOWN;
            }
        }
    }
    return netWorkType;
}
 
開發者ID:zengcanxiang,項目名稱:MVP-Practice-Project-Template,代碼行數:42,代碼來源:NetWorkStateUtils.java

示例11: updateNetworkType

/**
 * Updates the network type based upon the type and subtype returned from
 * the connectivity manager. Subtype is only used for cellular signals.
 * 
 * @param type
 * @param subType
 */
private void updateNetworkType(int type, int subType) {
    switch (type) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_ETHERNET:
        case ConnectivityManager.TYPE_BLUETOOTH:
            mIsCellularConnection = false;
            mIsAtLeast3G = false;
            mIsAtLeast4G = false;
            break;
        case ConnectivityManager.TYPE_WIMAX:
            mIsCellularConnection = true;
            mIsAtLeast3G = true;
            mIsAtLeast4G = true;
            break;
        case ConnectivityManager.TYPE_MOBILE:
            mIsCellularConnection = true;
            switch (subType) {
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE: // 4G
                case TelephonyManager.NETWORK_TYPE_EHRPD: // 3G ++ interop
                                                          // with 4G
                case TelephonyManager.NETWORK_TYPE_HSPAP: // 3G ++ but
                                                          // marketed as
                                                          // 4G
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = true;
                    break;
                default:
                    mIsCellularConnection = false;
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
            }
    }
}
 
開發者ID:SlotNSlot,項目名稱:SlotNSlot_Android,代碼行數:57,代碼來源:DownloaderService.java

示例12: 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,代碼來源:NetUtil.java

示例13: 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:harrylefit,項目名稱:EazyBaseMVP,代碼行數:49,代碼來源:NetWorkUtils.java

示例14: getNetworkTypeName

public static String getNetworkTypeName(int networkType) {
    switch (networkType) {
        // 2G
        case TelephonyManager.NETWORK_TYPE_1xRTT:
            return "1xRTT";
        case TelephonyManager.NETWORK_TYPE_CDMA:
            return "CDMA";
        case TelephonyManager.NETWORK_TYPE_EDGE:
            return "EDGE";
        case TelephonyManager.NETWORK_TYPE_GPRS:
            return "GPRS";
        case TelephonyManager.NETWORK_TYPE_IDEN:
            return "IDEN";

        // 3G
        case TelephonyManager.NETWORK_TYPE_EHRPD:
            return "EHRPD";
        case TelephonyManager.NETWORK_TYPE_EVDO_0:
            return "EVDO_0";
        case TelephonyManager.NETWORK_TYPE_EVDO_A:
            return "EVDO_A";
        case TelephonyManager.NETWORK_TYPE_EVDO_B:
            return "EVDO_B";
        case TelephonyManager.NETWORK_TYPE_HSDPA:
            return "HSDPA";
        case TelephonyManager.NETWORK_TYPE_HSPA:
            return "HSPA";
        case TelephonyManager.NETWORK_TYPE_HSPAP:
            return "HSPAP";
        case TelephonyManager.NETWORK_TYPE_HSUPA:
            return "HSUPA";
        case TelephonyManager.NETWORK_TYPE_UMTS:
            return "UMTS";
        case NETWORK_TYPE_TD_SCDMA:
            return "TD_SCDMA";

        // 4G
        case TelephonyManager.NETWORK_TYPE_LTE:
            return "LTE";
        case NETWORK_TYPE_IWLAN:
            return "IWLAN";

        default:
            return Integer.toString(networkType);
    }
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:46,代碼來源:Util.java

示例15: updateBatchSize

/**
 * Update batch size based on network type and status
 *
 * @param context the context, usually the application context
 */
public static int updateBatchSize(@Nullable final Context context) {
    if (context == null) {
        sBatchSize = 6;
        return sBatchSize;
    }

    // No network, use small batch size
    NetworkInfo info = getNetworkInfo(context);
    if (info == null || !info.isConnected()) {
        sBatchSize = 6;
        return sBatchSize;
    }

    // In WiFi, use large batch size
    if (info.getType() == ConnectivityManager.TYPE_WIFI) {
        sBatchSize = 24;
        return sBatchSize;
    }

    if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
        switch (info.getSubtype()) {
            case TelephonyManager.NETWORK_TYPE_HSDPA: // ~ 2-14 Mbps
            case TelephonyManager.NETWORK_TYPE_HSUPA: // ~ 1-23 Mbps
            case TelephonyManager.NETWORK_TYPE_EHRPD: // ~ 1-2 Mbps
            case TelephonyManager.NETWORK_TYPE_EVDO_B: // ~ 5 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPAP: // ~ 10-20 Mbps
            case TelephonyManager.NETWORK_TYPE_LTE: // ~ 10+ Mbps
                sBatchSize = 24;
                break;
            case TelephonyManager.NETWORK_TYPE_EVDO_0: // ~ 400-1000 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_A: // ~ 600-1400 kbps
            case TelephonyManager.NETWORK_TYPE_HSPA: // ~ 700-1700 kbps
            case TelephonyManager.NETWORK_TYPE_UMTS: // ~ 400-7000 kbps
                sBatchSize = 12;
                break;
            case TelephonyManager.NETWORK_TYPE_IDEN: // ~25 kbps
            case TelephonyManager.NETWORK_TYPE_CDMA: // ~ 14-64 kbps
            case TelephonyManager.NETWORK_TYPE_1xRTT: // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_EDGE: // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_GPRS: // ~ 100 kbps
            case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            default:
                sBatchSize = 6;
                break;
        }
    } else {
        // In other undetermined network, use small batch size
        sBatchSize = 6;
    }
    return sBatchSize;
}
 
開發者ID:Tenor-Inc,項目名稱:tenor-android-core,代碼行數:56,代碼來源:AbstractNetworkUtils.java


注:本文中的android.telephony.TelephonyManager.NETWORK_TYPE_EHRPD屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。