Determine which mobile operator the SIM card belongs

Source: Internet
Author: User

Method 1:

Obtain the imsi code of the mobile phone and determine whether it is China Mobile, China Unicom, or China Telecom.

Telephonymanager telmanager = (telephonymanager) getsystemservice (context. telephony_service );

/** Get the imsi code of the SIM card

* Unique SIM card ID: imsi
Imsi: internationalmobile
Subscriber identification number) is the identifier for distinguishing mobile users,

* It is stored in the SIM card and can be used to distinguish valid information of mobile users. Imsi is composed of MCC, MNC, and msin. MCC is a mobile country number and consists of three digits,

* The only country that identifies a mobile customer is China's 460. the MNC is the network ID, which consists 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, China Telecom is 03, and msin is the mobile customer identification code, which consists 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.

*/

Stringimsi = 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, and segment 134/159 uses this number.

// China Mobile

} Elseif (imsi. startswith ("46001 ")){

// China Unicom

} Elseif (imsi. startswith ("46003 ")){

// China Telecom

}

}

Method 2

Telephonymanager telmanager = (telephonymanager) getsystemservice (context. telephony_service );

Stringoperator = telmanager. getsimoperator ();

If (Operator! = NULL ){

If (operator. Equals ("46000") | Operator. Equals ("46002 ")){

// China Mobile

} Elseif (operator. Equals ("46001 ")){

// China Unicom

} Elseif (operator. Equals ("46003 ")){

// China Telecom

}

}

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.