Android native number and SIM card status acquisition

Source: Internet
Author: User

The data stored by the SIM card can be divided into four categories:
the first class is fixed-storage data. This data is written by the SIM card center before the mobile phone is sold, including the International Mobile Subscriber Identification Number (IMSI), authentication key (KI), authentication and encryption algorithms, and so on.
The second type is temporary storage of data about the network. such as the location Area identification Code (LAI), mobile User temporary identification number (TMSI), prohibit access to the public telephone network code.
The third category is the relevant business code,such as personal identification Number (PIN), unlock code (PUK), billing rate, and so on.
The fourth category is the phone book,Is the phone number that the mobile user has entered at any time. All of the user information is stored in the SIM card, so the SIM card is also called the User Data identification card.

IMSI is a unique number that identifies the only user in the GSM and UMTS networks. It is stored in the SIM card of the phone and it is sent to the network via the phone. The IMSI is the only one that corresponds to SIM.
The IMEI is also a unique number that identifies the only mobile phone in the GSM and UMTS networks. It is usually printed on the side of the battery below the cell phone and dials * #06 # to see it. The IMEI corresponds to the device only.
1. The IMEI does not exist in the SIM card, it is the serial number of the phone itself.
2.   Usually we call the mobile phone number also does not exist in the SIM card, although the SIM card has a special place to store the SIM card number, but this number is manually set, and can be changed. SIM card recognition usually uses the IMSI number, which is unique to the SIM card.
3. Using a function such as simgetrecordinfo to get the IMSI number of a SIM card depends on whether the device manufacturer has implemented this function, which I know is available on the Dopod machine, but not on the Lenovo machine, not the other machines.
4. The acquisition of IMEI and IMSI can be obtained by means of Ril or the line operation in TAPI.


Here is the code to get the phone's native number and SIM card status:
Telephonymanager TM = (Telephonymanager) this.getsystemservice (Context.telephony_service);
String DeviceID = Tm.getdeviceid ();
String Tel = tm.getline1number ();
String IMEI = Tm.getsimserialnumber ();
String IMSI = Tm.getsubscriberid ();
String simstate = Tm.getsimstate ();


Add Permissions:
<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>

Note that mobile phone numbers are not available for all. Just a part of it can get. This is due to the fact that the mobile operator does not write data from the mobile phone number to the SIM card. This is like a variable, and when the mobile operator assigns it a value, it will naturally have a value. No value is naturally empty. That's why many people don't get a native number.

Noun Explanation:
IMEI: (International Mobile Equipment Identity) is an abbreviation for International mobile device Identification Code, the International Mobile Equipment Identification Code, is a 15-digit "electronic serial number", which corresponds to one by one of each mobile phone, and the code is the only one in the world. Each handset will be given a globally unique set of numbers that will be recorded by the manufacturer of the manufacturing process, from production to delivery.

IMSI: (internationalmobilesubscriberidentificationnumber) International Mobile User identification Code, which is a sign that distinguishes mobile users, is stored in a SIM card and can be used to distinguish valid information from mobile users. The total length does not exceed 15 bits, and the same number is used for 0~9. MCC is the mobile user's country code, accounting for 3 digits, China's MCC is 460;MNC is a mobile network number, up to two digits, to identify mobile users belonging to the mobile communication network; Msin is a mobile user identification code to identify mobile users in a mobile communication network.

Android native number and SIM card status acquisition

Related Article

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.