Android determines which mobile operator the SIM card belongs to
The first method:
Get the IMSI code of the mobile phone, and judge that China Mobile \ Chinese Unicom Telecom
Telephonymanager Telmanager = (telephonymanager) getsystemservice (context.telephony_service);
/** gets the SIM card's IMSI code
* SIM card Unique ID: IMSI International Mobile User identification Code (imsi:international Mobile Subscriber identification number) is a sign that distinguishes mobile users,
* stored in a SIM card that can be used to differentiate valid information from mobile users. IMSI is composed of MCC, MNC, Msin, of which MCC is the mobile country number, composed of 3 digits,
* Uniquely identify the country to which the mobile customer belongs, and our country is 460;MNC as the network ID, consisting of 2 digits,
* To identify the mobile network to which the mobile customer belongs, China Mobile is 00, Unicom is 01, Chinese Telecom is 03;msin for mobile customer identification code, with equal length of 11 digits composition.
* Uniquely identify the domestic GSM mobile communication network to move customers. So to distinguish between moving or unicom, just get the MNC field in the SIM card can be
*
/String IMSI = Telmanager.getsubscriberid ();
if (imsi!=null) {
if (Imsi.startswith ("46000") | | imsi.startswith ("46002")) {//Because the IMSI under mobile network number 46000 has been exhausted, So virtual a 46002 number, 134/159th segment using this number
//China Mobile
}else if (Imsi.startswith ("46001")) {//
China Unicom
}else if ( Imsi.startswith ("46003")) {
//China Telecom
}
}
The second method
Telephonymanager Telmanager = (telephonymanager) getsystemservice (context.telephony_service);
String operator = Telmanager.getsimoperator ();
if (operator!=null) {
if (operator.equals ("46000") | | operator.equals ("46002")) {
//China Mobile
}else if ( Operator.equals ("46001")) {//
unicom
}else if (operator.equals ("46003")) {
//China Telecom
}
}
Thank you for reading, I hope to help you, thank you for your support for this site!