Android-get the imsi code of the mobile phone and determine whether it is China Mobile, China Unicom, or China Telecom

Source: Internet
Author: User
Telephonymanager telmanager = (telephonymanager) getsystemservice (context. telephony_service);/** get the imsi code of the SIM card * unique ID of the SIM card: imsi International Mobile User identification code (imsi: International Mobile Subscriber identification number) is the identifier that distinguishes mobile users, * It is stored in the SIM card and can be used to distinguish valid information of mobile users. Imsi consists of MCC, MNC, and msin. Among them, MCC is a mobile country number consisting of three digits. * It uniquely identifies the country to which mobile customers belong, and China is 460; MNC is a network ID consisting of two digits. * It is used to identify the mobile network to which a mobile customer belongs. China Mobile is 00, China Unicom is 01, and China Telecom is 03; msin is a mobile customer identification code consisting of 11 digits. * Uniquely identifies China Mobile clients in the domestic GSM mobile communication network. To distinguish between mobile and Unicom, you only need to obtain the MNC field in the SIM card */string imsi = telmanager. getsubscriberid (); If (imsi! = NULL) {If (imsi. startswith ("46000") | imsi. startswith ("46002") {// because imsi under mobile network number 46000 is used up, A 46002 number is virtualized, section 134/159 uses this ID // China Mobile} else if (imsi. startswith ("46001") {// China Unicom} else if (imsi. startswith ("46003") {// China Telecom }}

Imsi: International Mobile User identification code (unique identifier), imsi = MCC + MNC + msin, where MCC refers to the mobile station country code (3 bits, 460 in China ), MNC refers to the mobile network code (2-digit China 00), and msin refers to the mobile user identification number (10 digits)

Imsi has a total of 15 digits, and its structure is as follows:

MCC + MNC + msin, (MNC + msin = nmsi)

MCC: Mobile country code, mobile country code, and MCC resources are centrally allocated and managed by ITU (ITU). The only country that identifies a mobile user is located in three places, with 460 in China;

MNC: mobile network code, mobile network code, two digits in total, China Mobile TD system 00, China Unicom GSM system 01, China Mobile GSM system 02, China Telecom CDMA system 03, the typical imsi number is 460030912121001;

Msin: mobile subscriber identification number has a total of 10 digits. Its structure is as follows:

09 + m0m1m2m3 + ABCD

Among them, the m0m1m2m3 and the h0h1h2h3 in the mdn number can have a correspondence relationship, and the four bits of ABCD are freely allocated.

We can see that imsi has added MCC (nmsi) To The msin number, which can distinguish the countries from which each user comes, so that it can implement international roaming. In the same country, if there are multiple mobile network operators, you can use MNC to differentiate them.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.