Android operator and Network Type Analysis
For some requirements, you need to obtain the carrier and network type, and analyze the carrier and network type.
First, we will throw some nonsense definitions:
GSM: The Global System of Mobile communication is a well-known GSM, the most widely used Mobile phone standard.
CDMA: Code Division Multiple Access (CDMA) is a new and mature wireless communication technology developed from the Spread Spectrum Communication Technology, a branch of digital technology.
It can be seen that the two are technical standards and have nothing to do with the network type and standard.
Go to the topic.
1. Get the phone type
This can be obtained through the method TelephonyManager # getPhoneType. The following is the return type.
/** * Returns a constant indicating the device phone type. This * indicates the type of radio used to transmit voice calls. * * @see #PHONE_TYPE_NONE * @see #PHONE_TYPE_GSM * @see #PHONE_TYPE_CDMA * @see #PHONE_TYPE_SIP */
Common types of phones are GSM and CDMA. SIP is related to VOIP, which is not frequently used.
2. Get Carrier
TelephonyManager # getSimOperator is used to obtain the ID of the SIM card carrier. For example, if mobile is 46002
TelephonyManager # getSimOperatorName method to obtain the carrier name. For example, if mobile is CMCC
TelephonyManager # getSimCountryIso gets the SIM card country. For example, if China is cn
TelephonyManager # getSimState to get SIM card status
3. Obtain the network type
The point is.
TelephonyManager # getNetworkType method to obtain the network type.
To precisely display the current network of the mobile phone, such as "China Unicom 3G", you need this.
I found some code on the Internet and saw some Code marked after some network types: "Mobile 2G". I just want to say "Haha ".
The reason is that this cannot be determined from a single network type.
Return to the topic and start to analyze the returned values.
1) NETWORK_TYPE_GPRS
GPRS is a standard, equivalent to 2.5 GB. It exists independently of the phone type. Although mobile devices are GSM phones and Unicom is CDMA phones, they can all have this standard,
Take the example of Mobile 2G. My city is EDGE network. However, before China Mobile and China Unicom used GPRS at the same time,
At the same time, it is not ruled out that GPRS is still deployed in some regions, so we do not agree with the predecessor who marked "Mobile 2G" behind the code.
2) NETWORK_TYPE_EDGE
EDGE should be 2.75 GB. As far as I know, China Unicom does not seem to have upgraded the 2G network to this standard. Mobile is currently using this.
3) NETWORK_TYPE_UMTS
UMTS is defined as a 3G mobile phone technology that uses WCDMA as the underlying standard and is backward compatible with GSM networks.
Currently, China only has China Unicom. This is the only way to determine the operator and its network type.
4) NETWORK_TYPE_CDMA
The definition of CDMA is a technical standard, with its 2-generation, 2.5-generation, and 3-generation technologies. It is considered as the first choice of the three-generation mobile technology. The standards included include:
WCDMA, CDMA 2000, and TD-SCDMA. Here, CDMA refers to the standard of the CDMA 2 generation technical standard, which is in use by China Telecom.
5) NETWORK_TYPE_1xRTT
In CDMA 2.75, it is generally considered to be 2G or G, and the speed is only a fraction of the other 3G, which may be used by China Telecom.
6) NETWORK_TYPE_EVDO_0, NETWORK_TYPE_EVDO_A, and NETWORK_TYPE_EVDO_ B
Both are in the standard version of CDMA 2000, which belongs to 3 GB and may be used by China Telecom.
7) NETWORK_TYPE_HSDPA
A communication protocol established on WCDMA, equivalent to 3.5 GB, which may be used by China Unicom.
8) NETWORK_TYPE_LTE
It corresponds to a quasi-4 GB, which may be used by various operators.
9) NETWORK_TYPE_GSM
This value is hidden and the value is 16. You do not know what card will appear. The conjecture should be the earliest standard corresponding to the GSM standard without verification.
10) network_type_td_td-scdma
It is also hidden. The value is 17. This value is used when 3G is moved.
Conclusion: The network type of the operator should not be determined based on NetworkType.
The carrier obtains the value separately, and the NetworkType can be further known as 2G or 3G.
Other standards that do not exist in China will not be judged first.
4. android compatibility
For devices with low android versions that do not contain some type definitions, it is best to redefine these network type variables in your own classes.