android 2g3g网,android – 如何确定网络类型是2G,3G还是4G

我有一个指示器在我的应用程序显示网络类型(2G或3G或4G),但获得网络类型后,我如何知道应该在什么速度类别?

我知道如何检测网络类型:

private TelephonyManager telephonyManager;

telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

CurrentNetworkType = telephonyManager.getNetworkType();

给定可能的返回值:

// public static final int NETWORK_TYPE_1xRTT

// Since: API Level 4

// Current network is 1xRTT

// Constant Value: 7 (0x00000007)

//

// public static final int NETWORK_TYPE_CDMA

// Since: API Level 4

// Current network is CDMA: Either IS95A or IS95B

// Constant Value: 4 (0x00000004)

//

// public static final int NETWORK_TYPE_EDGE

// Since: API Level 1

// Current network is EDGE

// Constant Value: 2 (0x00000002)

//

// public static final int NETWORK_TYPE_EHRPD

// Since: API Level 11

// Current network is eHRPD

// Constant Value: 14 (0x0000000e)

//

// public static final int NETWORK_TYPE_EVDO_0

// Since: API Level 4

// Current network is EVDO revision 0

// Constant Value: 5 (0x00000005)

//

// public static final int NETWORK_TYPE_EVDO_A

// Since: API Level 4

// Current network is EVDO revision A

// Constant Value: 6 (0x00000006)

//

// public static final int NETWORK_TYPE_EVDO_B

// Since: API Level 9

// Current network is EVDO revision B

// Constant Value: 12 (0x0000000c)

//

// public static final int NETWORK_TYPE_GPRS

// Since: API Level 1

// Current network is GPRS

// Constant Value: 1 (0x00000001)

//

// public static final int NETWORK_TYPE_HSDPA

// Since: API Level 5

// Current network is HSDPA

// Constant Value: 8 (0x00000008)

//

// public static final int NETWORK_TYPE_HSPA

// Since: API Level 5

// Current network is HSPA

// Constant Value: 10 (0x0000000a)

//

// public static final int NETWORK_TYPE_HSPAP

// Since: API Level 13

// Current network is HSPA+

// Constant Value: 15 (0x0000000f)

//

// public static final int NETWORK_TYPE_HSUPA

// Since: API Level 5

// Current network is HSUPA

// Constant Value: 9 (0x00000009)

//

// public static final int NETWORK_TYPE_IDEN

// Since: API Level 8

// Current network is iDen

// Constant Value: 11 (0x0000000b)

//

// public static final int NETWORK_TYPE_LTE

// Since: API Level 11

// Current network is LTE

// Constant Value: 13 (0x0000000d)

//

// public static final int NETWORK_TYPE_UMTS

// Since: API Level 1

// Current network is UMTS

// Constant Value: 3 (0x00000003)

//

// public static final int NETWORK_TYPE_UNKNOWN

// Since: API Level 1

// Network type is unknown

// Constant Value: 0 (0x00000000)

我会考虑LTE是4G,但其中哪些真正考虑3G?

还有我会考虑2G。

那么,你在哪里画3G或不3G?

更新:

我在http://stackoverflow.com/a/8548926/949577找到另一个相关的答案

它使用ConnectivityManager()获取类型和子类型,然后将子类型分类为快或不快。

我不知道如果使用ConnectivityManager()是一个更好的方法,然后使用TelephonyManager(),因为他们都可以返回网络类型。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值