Get MSISDN from the SIM using Android

吃可爱长大的小学妹 提交于 2019-11-27 14:58:23

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/8570945/get-msisdn-from-the-sim-using-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!