I'm trying to retrieve the MSISDN from the SIM using Android, I have tried getLine1Number() but this only returns the MSISDN stored in My Phone Information or Owner Information secction, if these info is not stored, Android will return a null value.
Do you know any work around from this? or is there a way to derive the MSISDN from the SIM number (getSimSerialNumber())?
Awaits a solid Answer as always !!! :)
The MSISDN (aka the mobile phone number) isn't a SIM data, so you can't retrieve it. The SIM card has an IMSI (International Mobile Subsriber Identity) that is sent to the HLR (Home Location Register) in charge of doing the mapping MSISDN/IMSI.
Mobile phone operators could store the MSISDN on the SIM card if they wanted to, but since it is not required in the GSM protocol it isn't.
Sorry!
For more info look at this discussion Getting phone number also How android get MSISDN
EDIT:
To get IMSI number,
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imsi = mTelephonyMgr.getSubscriberId();
but a few handsets only return 6 digits instead of 15. So, you can use,
According to this post: http://www.anddev.org/tinytut_-_getting_the_imsi_-_imei_sim-device_unique_ids-t446.html
String imei = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI);
For more info look at This Question and class SystemProperties
Related
I used this code for fetching the number, But it gave me null
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
It may not always return mobile number.
Let me explain how this actually works: When you buy a new SIM card for a new number, the provider had already (though not always) put a mobile number in the SIM (SIM Cards do have a little memory). Now TelephonyManager API tries to read that number. If it is available then it returns the number.
Now, you can get a SIM without a mobile number associated with it. Example - new SIM for porting (where you use previous number in new SIM Card). Those SIMs don't have any number stored on them, and hence TelephonyManager returns null.
Now, even if TelephonyManager returns a number, you should not trust it to be right. Because many devices provide option to edit that number.
To use getLine1Number() you need either READ_PHONE_STATE OR READ_SMS permission. You may be missing that.
And remember that it returns null if phone number string is unavailable.
I used the following code to get to get the sim number and serial number of the sim. But i am getting the sim serial number but not the sim number. I gave the uses permission all the stuffs like that. but i am not getting it.!! Please help me out.!! Thank You.!
TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = telemamanger.getSimSerialNumber();
String getSimNumber = telemamanger.getLine1Number();
SIM number is not compulsory to be there, it's upto the Telecom if they put number inside the SIM card. It's mostly happen they do it for POSTPAID SIM cards, mostly SIMs do not have number so in that case they return null and if it has, it shall return that NUMBER as it is. To make sure your SIM has number or not, do check that in your android mobile settings.
check this link Check SIM number in android
I am developing an application that requires the IMSI/phone number of the device(with multiple SIM cards) which receives an sms.
This is basically for identification purpose of which SIM is receiving the sms and later perform further operations.
I have thoroughly searched the SMSMessage Api, but did not find a suitable solution.
Any help would be greatly appreciated.
As I know you can not get the destination phone number, IMSI from the incoming SMS.
You can get the IMSI and phone Number of SIM like this way.
You can get the IMSI number of SIM but I don't think you will be able to get the phone number of all SIM because some manufacture did not save the phone number in SIM so you will get the NULL.
In Android, No way using Android SDK to get the second SIM information. You can get the information of first SIM only.
Android SDK support the first SIM information and Dual SIM features are available from manufacture side hence not officially supported from Android SDK.
Add this AndroidManifest.xml
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Add this in where you want to get SIM details.
TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
To get the IMSI of 1st SIM
String imsi = telemamanger.getSimSerialNumber();
To get the Phone Number of 1st SIM
if(telemamanger.getLine1Number() != null)
String phoneNumber = telemamanger.getLine1Number();
I have implemented an application for get the SIM cards mobile numbers from my Google Ebony QWERTY touchscreen.In this device i have two SIM cards.I have used TelephonyManager for get mobile number from device as follows
TelephonyManager tMgr = (TelephonyManager) arTnewActivity.getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = tMgr.getLine1Number();
Log.v("Device mobile numbers",getSimSerialNumber);
From the above code it will return a single mobile number but If i run in case of Ebony QWERTY dual sim phone then can i get two sim card serial numbers?
please any body help me..
From what I understand the default SDK does not have support to handle dual sim. From this thread it sounds like you have to ask the manufacturer if they have a special SDK that could provide this.
If it's Google they might have some additional SDK stuffed away somewhere? :-)
I want to retreive mobile number of device programatically. My code is:-
TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
String strMobileNumber = telephonyManager.getLine1Number();
and I have set READ_PHONE_STATE permission in AndroidManifest.xml file. This is working on emulator but on actual device with eclair version, it is returning empty string. Is there any other way to get mobile no?
There is no reliable way to "retreive mobile number of device programatically", AFAIK. getLine1Number() reports the number supplied by the SIM card for GSM phones, and the mobile number does not need to be on the SIM card.