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


Java TelephonyManager.NETWORK_TYPE_HSDPA属性代码示例

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


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

示例1: getNetworkClass

/**
 * 获取在Mobile网络下的网络类型. 2G,3G,4G
 * 
 * @param context
 * @return
 */
public static int getNetworkClass(Context context) {
	ConnectivityManager connectivityManager = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);
	if (connectivityManager != null) {
		NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
		if (networkInfo != null) {
			if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
				switch (networkInfo.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 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 12: // TelephonyManager.NETWORK_TYPE_EVDO_B:
				case 14: // TelephonyManager.NETWORK_TYPE_EHRPD:
				case 15: // TelephonyManager.NETWORK_TYPE_HSPAP:
					return NETWORK_CLASS_3_G;
				case 13: // TelephonyManager.NETWORK_TYPE_LTE:
					return NETWORK_CLASS_4_G;
				default:
					return NETWORK_CLASS_UNKNOWN;
				}
			} else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
				return NETWORK_CLASS_WIFI;
			}
		}
	}
	return NETWORK_CLASS_UNKNOWN;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:42,代码来源:NetworkUtil.java

示例2: getCurrentNetworkType

/**
 * 获取手机当前网络类型
 */
public static String getCurrentNetworkType(Context context) {
    String type = "";
    ConnectivityManager cm = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();
    if (info == null) {
        type = "null";
    } else if (info.getType() == ConnectivityManager.TYPE_WIFI) {
        type = "wifi";
    } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
        int subType = info.getSubtype();
        if (subType == TelephonyManager.NETWORK_TYPE_CDMA
                || subType == TelephonyManager.NETWORK_TYPE_GPRS
                || subType == TelephonyManager.NETWORK_TYPE_EDGE) {
            type = "2g";
        } else if (subType == TelephonyManager.NETWORK_TYPE_UMTS
                || subType == TelephonyManager.NETWORK_TYPE_HSDPA
                || subType == TelephonyManager.NETWORK_TYPE_EVDO_A
                || subType == TelephonyManager.NETWORK_TYPE_EVDO_0
                || subType == TelephonyManager.NETWORK_TYPE_EVDO_B) {
            type = "3g";
        } else if (subType == TelephonyManager.NETWORK_TYPE_LTE) {// LTE是3g到4g的过渡,是3.9G的全球标准
            type = "4g";
        }
    }
    return type;
}
 
开发者ID:jiajieshen,项目名称:AndroidDevSamples,代码行数:30,代码来源:NetworkUtil.java

示例3: getNetworkClass

/**
 * 获取在Mobile网络下的网络类型. 2G,3G,4G
 *
 * @param context
 * @return
 */
public static int getNetworkClass(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivityManager != null) {
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
        if (networkInfo != null) {
            if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
                switch (networkInfo.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 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 12: // TelephonyManager.NETWORK_TYPE_EVDO_B:
                    case 14: // TelephonyManager.NETWORK_TYPE_EHRPD:
                    case 15: // TelephonyManager.NETWORK_TYPE_HSPAP:
                        return NETWORK_CLASS_3_G;
                    case 13: // TelephonyManager.NETWORK_TYPE_LTE:
                        return NETWORK_CLASS_4_G;
                    default:
                        return NETWORK_CLASS_UNKNOWN;
                }
            } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
                return NETWORK_CLASS_WIFI;
            }
        }
    }
    return NETWORK_CLASS_UNKNOWN;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:42,代码来源:NetworkUtil.java

示例4: getAPNType

/**
 * 获取当前的网络状态 :没有网络-0:WIFI网络1:4G网络-4:3G网络-3:2G网络-2
 * 自定义
 *
 * @param context
 * @return
 */
public static int getAPNType(Context context) {
    //结果返回值
    int netType = 0;
    //获取手机所有连接管理对象
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    //获取NetworkInfo对象
    NetworkInfo networkInfo = manager.getActiveNetworkInfo();
    //NetworkInfo对象为空 则代表没有网络
    if (networkInfo == null) {
        return netType;
    }
    //否则 NetworkInfo对象不为空 则获取该networkInfo的类型
    int nType = networkInfo.getType();
    if (nType == ConnectivityManager.TYPE_WIFI) {
        //WIFI
        netType = 1;
    } else if (nType == ConnectivityManager.TYPE_MOBILE) {
        int nSubType = networkInfo.getSubtype();
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        //3G   联通的3G为UMTS或HSDPA 电信的3G为EVDO
        if (nSubType == TelephonyManager.NETWORK_TYPE_LTE
                && !telephonyManager.isNetworkRoaming()) {
            netType = 4;
        } else if (nSubType == TelephonyManager.NETWORK_TYPE_UMTS
                || nSubType == TelephonyManager.NETWORK_TYPE_HSDPA
                || nSubType == TelephonyManager.NETWORK_TYPE_EVDO_0
                && !telephonyManager.isNetworkRoaming()) {
            netType = 3;
            //2G 移动和联通的2G为GPRS或EGDE,电信的2G为CDMA
        } else if (nSubType == TelephonyManager.NETWORK_TYPE_GPRS
                || nSubType == TelephonyManager.NETWORK_TYPE_EDGE
                || nSubType == TelephonyManager.NETWORK_TYPE_CDMA
                && !telephonyManager.isNetworkRoaming()) {
            netType = 2;
        } else {
            netType = 2;
        }
    }
    return netType;
}
 
开发者ID:Mrqinlei,项目名称:ImitateZHRB,代码行数:47,代码来源:NetworkUtils.java

示例5: getNetworkType

/**
 * 判断当前网络类型-1为未知网络0为没有网络连接1网络断开或关闭2为以太网3为WiFi4为2G5为3G6为4G
 */
public static int getNetworkType(Context context) {
	ConnectivityManager connectMgr = (ConnectivityManager) context
			.getSystemService(Context.CONNECTIVITY_SERVICE);

	NetworkInfo networkInfo = connectMgr.getActiveNetworkInfo();
	if (networkInfo == null) {
		/** 没有任何网络 */
		return 0;
	}
	if (!networkInfo.isConnected()) {
		/** 网络断开或关闭 */
		return 1;
	}
	if (networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) {
		/** 以太网网络 */
		return 2;
	} else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
		/** wifi网络,当激活时,默认情况下,所有的数据流量将使用此连接 */
		return 3;
	} else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
		/** 移动数据连接,不能与连接共存,如果wifi打开,则自动关闭 */
		switch (networkInfo.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:
			/** 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:
		case TelephonyManager.NETWORK_TYPE_EHRPD:
		case TelephonyManager.NETWORK_TYPE_HSPAP:
			/** 3G网络 */
		case TelephonyManager.NETWORK_TYPE_LTE:
			/** 4G网络 */
			return 4;
		}
	}
	/** 未知网络 */
	return -1;
}
 
开发者ID:CoderCF,项目名称:SuperVideoPlayer,代码行数:49,代码来源:NetUtils.java

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

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

示例8: getNetworkType

/**
 * GPRS    2G(2.5) General Packet Radio 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 Down link 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 networkType = getTelephonyManager(context).getNetworkType();
            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:
                    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:wzx54321,项目名称:XinFramework,代码行数:56,代码来源:Network.java

示例9: getCurrentNetState

/**
 * get the net state of current
 * @param context the context.
 * @return the state code. see {@linkplain #STATE_2G} and etc.
 */
public static byte getCurrentNetState(Context context) {
    byte code = STATE_NO;
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo ni = cm.getActiveNetworkInfo();
    if (ni != null && ni.isConnectedOrConnecting()) {
        switch (ni.getType()) {
            //wifi
            case ConnectivityManager.TYPE_WIFI:
                code = STATE_WIFI;
                break;
            //mobile 网络
            case ConnectivityManager.TYPE_MOBILE:
                switch (ni.getSubtype()) {
                    case TelephonyManager.NETWORK_TYPE_GPRS: //联通2g
                    case TelephonyManager.NETWORK_TYPE_CDMA: //电信2g
                    case TelephonyManager.NETWORK_TYPE_EDGE: //移动2g
                    case TelephonyManager.NETWORK_TYPE_1xRTT:
                    case TelephonyManager.NETWORK_TYPE_IDEN:
                        code = STATE_2G;
                        break;
                    case TelephonyManager.NETWORK_TYPE_EVDO_A: //电信3g
                    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:
                        code = STATE_3G;
                        break;
                    case TelephonyManager.NETWORK_TYPE_LTE://4G
                        code = STATE_4G;
                        break;

                    default:
                        code = STATE_UNKNOWN;
                }
                break;
            default:
                code = STATE_UNKNOWN;
        }
    }
    return code;
}
 
开发者ID:LightSun,项目名称:android-util2,代码行数:50,代码来源:NetHelper.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:lai233333,项目名称:MyDemo,代码行数:49,代码来源:NetUtil.java

示例11: GetNetworkType

public static String GetNetworkType() {
    String strNetworkType = "";

    ConnectivityManager cm = (ConnectivityManager) mContext
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = cm.getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isConnected()) {
        if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
            strNetworkType = "WIFI";
        } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
            String _strSubTypeName = networkInfo.getSubtypeName();

            Log.e("cocos2d-x", "Network getSubtypeName : " + _strSubTypeName);
            // 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 = "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 = "3G";
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE:    //api<11 : replace by 13
                    strNetworkType = "4G";
                    break;
                default:
                    // http://baike.baidu.com/item/TD-SCDMA 中国移动 联通 电信 三种3G制式
                    if (_strSubTypeName.equalsIgnoreCase("TD-SCDMA") || _strSubTypeName.equalsIgnoreCase("WCDMA") || _strSubTypeName.equalsIgnoreCase("CDMA2000")) {
                        strNetworkType = "3G";
                    } else {
                        strNetworkType = _strSubTypeName;
                    }

                    break;
            }

        }
    }

    return strNetworkType;
}
 
开发者ID:paradoxie,项目名称:DizzyPassword,代码行数:53,代码来源:MyApplication.java

示例12: isFastMobileNetwork

/**
 * Whether is fast mobile network
 */

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:jeasinlee,项目名称:AndroidBasicLibs,代码行数:47,代码来源:NetUtils.java

示例13: getNetworkType

/**
 * 获取当前网络类型
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
 *
 * @return 网络类型
 * <ul>
 * <li>{@link NetworkType#NETWORK_WIFI   } </li>
 * <li>{@link NetworkType#NETWORK_4G     } </li>
 * <li>{@link NetworkType#NETWORK_3G     } </li>
 * <li>{@link NetworkType#NETWORK_2G     } </li>
 * <li>{@link NetworkType#NETWORK_UNKNOWN} </li>
 * <li>{@link NetworkType#NETWORK_NO     } </li>
 * </ul>
 */
public static NetworkType getNetworkType() {
    NetworkType netType = NetworkType.NETWORK_NO;
    NetworkInfo info = getActiveNetworkInfo();
    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:QuincySx,项目名称:AvenueNet,代码行数:68,代码来源: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:Gookler,项目名称:RxJanDan,代码行数:54,代码来源:Connectivity.java

示例15: 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:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:57,代码来源:DownloaderService.java


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