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
}
}