Android Get SIM card operator information
Telephonymanager TM = (Telephonymanager) context.getsystemservice (Context.telephony_service); Telephonymanager uses Telephonymanager to provide access to information about the communication service on the device, and the application uses this class of methods to obtain a service provider or status for the phone. The program can also register a listener to monitor phone status changes. You do not need to instantiate this class directly, use Context.getsystemservice (Context.telephony_service) to get an instance of this class.
Note: Some phone messages require the appropriate permissions. Invalid method
Getsimoperatorname () Returns the Service Provider Name (SPN). Get a service provider name, such as Telecom, Unicom, mobile Use the following method the first method: Get the IMSI code of the mobile phone, and Judge China Mobile/unicom/Chinese Telecom
Telephonymanager Telmanager = (telephonymanager) getsystemservice (Context.telephony_service);
/** get SIM card IMSI code * SIM card Unique ID: IMSI International Mobile User identification number (imsi:international Mobile subscriber Identification number) is the logo that distinguishes the mobile user, * Stored in a SIM card that can be used to distinguish valid information from a mobile user.
IMSI is composed of MCC, MNC, Msin, of which MCC is a mobile country number, consisting of 3 digits, * Uniquely identify the country that the mobile customer belongs to, our country is the network ID of the 460;MNC, and it is composed of 2 digits, * To identify mobile network belonging to mobile clients, China Mobile is 00, China Unicom is 01, Chinese Telecom is 03;
Msin is a mobile customer identification code, the use of equal length 11 digits. *
Uniquely identify the domestic GSM mobile communication network to move customers. So to distinguish between mobile or unicom, just get the MNC field in the SIM card */
String IMSI = Telmanager.getsubscriberid ();
if (imsi!=null) {if (Imsi.startswith ("46000″) | | | Imsi.startswith ("46002″)")
{//Because the mobile network number 46000 under the IMSI has run out, so virtual a 46002 number, 134/159th segment Use this number//China Mobile
}else if (Imsi.startswith ("46001″)") {
China Unicom
}else if (Imsi.startswith ("46003″)") {
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″) | | Operator.equals ("46007″)") {
Mobile
}else if (operator.equals ("46001″)") {
China Unicom
}else if (operator.equals ("46003″)") {
Telecom
} }
Add permissions in file Androidmanifest.xml Other ways to use this method please see the instructions in the API documentation Telephonymanager.
Add permissions in file Androidmanifest.xml <uses-permission android:name="Android.permission.READ_PHONE_STATE"/ >
Telephonymanager Tel = (telephonymanager) context. Getsystemservice (Context.telephony_service);
String simoperator = Tel.getsimoperator ();
IMSI a total of 15 bits, the structure of the following: Mcc+mnc+min mcc:mobile country Code, mobile country Code, a total of 3, China is 460; Mnc:mobile networks Code, mobile network Code, a total of 2 bits, telecommunications 03, Mobile 02, Unicom GSM 01, a typical IMSI number of 460030912121001; Min has a total of 10 bits, the structure is as follows: 09+M0M1M2M3+ABCD There is a correspondence between the M0M1M2M3 and the h0h1h2h3 in the MDN number, and the ABCD four bits are allocated freely. It can be seen that imsi in the min number before the MCC, can distinguish each user from the country, so can achieve international roaming. In the same country, if there are multiple CDMA operators, the MNC can be used to differentiate.
Function description
Getcelllocation () returns the cell position of the appliance access_coarse_location or access_fine_location
Getdeviceid () returns the Imei/meid device. If the device is a GSM device then the IMEI number will be returned if the device is a CDMA device then Meid will be returned read_phone_state
Getline1number () returns the phone number of the device (MSISDN number) read_phone_state
Getnetworkoperatorname () returns the name of the registered network operator
Getnetworkoperator () back to MCC + registered network operator of multinational companies
Getnetworkcountryiso () returns the country code of the registered network operator
Getsimcountryiso () returns the SIM card operator's country code read_phone_state
Getsimoperator () returns the number of individual nuclear cells of the SIM card operator + metallurgical read_phone_state
Getsimoperatorname () returns the name of the SIM card operator Read_phone_state
Getsimserialnumber () returns the serial number of the SIM card read_phone_state
Getnetworktype () returns the type of network device available. This will be one of the following values:
Telephonymanager.network_type_unknown Telephonymanager.network_type_gprs Telephonymanager.network_type_edge Telephonymanager.network_type_umts read_phone_state Getphonetype () returns the type of the device. This will be one of the following values: Telephonymanager.phone_type_none telephonymanager.phone_type_gsm TELEPHONYMANAGER.PHONE_TYPE_CDMA READ_ Phone_state Getsubscriberid () returns the device of the user ID (IMSI) read_phone_state
Getneighboringcellinfo () Returns the information of the Neighboringcellinfo class representing the neighboring cell, or returns NULL if available Access_coarse_updates