Get MSISDN from the SIM using Android
Asked Answered
G

1

11

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 !!! :)

Gosplan answered 20/12, 2011 at 4:49 Comment(0)
C
20

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 Subscriber 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:

String imei = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI);

For more info look at This Question and class SystemProperties

Ctn answered 20/12, 2011 at 4:59 Comment(1)
Yes, I found that out too ... but how do i retrieve the IMSI from the SIM using Andoid? any ideas?Gosplan

© 2022 - 2024 — McMap. All rights reserved.