O__O
O__O

Reputation: 970

Get the IMSI number or destination phone number from incomming message (SMS)

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.

Upvotes: 4

Views: 9537

Answers (1)

Ajay S
Ajay S

Reputation: 48602

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();

Upvotes: 4

Related Questions