4

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.

Kara
  • 6,115
  • 16
  • 50
  • 57
O__O
  • 950
  • 1
  • 9
  • 17

1 Answers1

4

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();
Ajay S
  • 48,003
  • 27
  • 91
  • 111
  • Thanks for you answer.But when I receive an sms how do I know programmatically that which sim is receiving the sms? – O__O Apr 30 '13 at 05:34
  • Actually, `telemamanger.getSimSerialNumber();` returns the ICCID (simcard serial number, unique and **printed** in the simcard). If you need the IMSI (which is **stored** in the simcard and can be changed), you will want `telemamanger.getSubscriberId(); ` Beware though, some manufacturer implementation only returns the non-personal digits of the IMSI (6 digits instead of 14-15) – baramuse Apr 24 '14 at 00:48
  • now in OS 5.1 and above we can get getSubscriberId() but how can i identify which SIM is receiving the sms from IMSI or getSubscriberId? – Achin Jun 19 '16 at 05:34