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. The SIM card only has the unique number, for the network and the device recognition that is the IMSI number, the cell phone signal also can say is passes through this number in the network, is not the mobile phone number. Just imagine, after your SIM is lost, do you have a new one that will change the number? No, it is because the IMSI number that corresponds to your mobile phone number is modified in the mobile operator to the IMSI number of the new SIM card.
So why does the phone number have to show it?
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.
For mobile users, the mobile number (MDN) is saved in the operator's server instead of being stored in the SIM card. The SIM card retains only IMSI and some verification information. Every time the mobile network registration, will be in the form of text messages to the IMSI and authentication information to the operator's server, the server after the completion of the registration action, will be in the form of text messages will be issued to the mobile phone. The content will be different depending on the conditions.
If the server in the issued text message, does not include the phone number, the phone is unable to obtain the phone number. If the text contains a number, the phone will cache it for his use. In addition, for other operators ' SIM cards or Uim cards, the MDN may be saved in the UIM card. 100% being able to get a native number is unlikely.
Mobile Shenzhou Line, Unicom's card can be taken. The dynamic zone is not available. Other cards have not been tried yet.
The ability to read the SIM card number should have a precondition. That is, the SIM card has been written to the local number, otherwise it cannot be read.
Specific processing code: (The program can not be implemented on the simulator, must be connected to the mobile phone)
Create Phone Management
Telephonymanager TM = (Telephonymanager)
Make a connection to your phone
Activity.getsystemservice (Context.telephony_service);
Get mobile phone number
String Phoneid = Tm.getline1number ();
Remember to add the manifest file
<uses-permission
Android:name= "Android.permission.READ_PHONE_STATE"/>
About Android read current mobile phone number