开发者

Detecting WCDMA and HSDPA on Android

开发者 https://www.devze.com 2023-02-14 09:11 出处:网络
I\'ve got an app that runs across Android versions 1.6+, and needs to detect the network type. I\'ve got a problem with HSDPA and WCDMA, though - the former only has a defined constant for TelephonyM

I've got an app that runs across Android versions 1.6+, and needs to detect the network type.

I've got a problem with HSDPA and WCDMA, though - the former only has a defined constant for TelephonyManager#getNetworkType in API version 5+, and the latter doesn't seem to have one at all.

Does anyone know what a phone on these network types will return for TelephonyManager#getNetworkType before and after Android 2.0? (I'm a开发者_开发技巧ssuming that on 2.0+ on an HSDPA network it'll return the appropriate constant, but the rest appear undefined...)


According to the source code for the TelephonyManager class in Android 1.6, the return value for HSPDA and WCDMA should be NETWORK_TYPE_UNKNOWN (0).

If you look at the constants defined in the Telephony Manager class documentation for the various network types, you can see when each network type was introduced to the API:

HSPDA: API version 5+
WCDMA: (Not documented)

Based on what I have read in wikipedia on WCDMA, it also goes by the name UMTS, which means that a WCDMA phone will return NETWORK_TYPE_UMTS (3).

Summary

HSPDA:

  • returns NETWORK_TYPE_UNKNOWN (0) in API Version 4 (Android <= 1.6)
  • returns NETWORK_TYPE_HSDPA (8) in API Version 5+ (Android 2.0+)

WCDMA:

  • returns NETWORK_TYPE_UMTS (3) since API Version 1

EDIT

I should also point out that, since Android is open source, its possible that the handset provider has overridden these values and functions, so it is possible that they may deviate from the trunk version.

0

精彩评论

暂无评论...
验证码 换一张
取 消