Get MSISDN from the SIM using Android

前端 未结 1 1209
有刺的猬
有刺的猬 2020-12-15 09:54

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

相关标签:
1条回答
  • 2020-12-15 10:17

    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

    0 讨论(0)
提交回复
热议问题