How to figure out which SIM received SMS in Dual SIM Android Device

I had some really hard time with this problem and finally I found a solution, although i tested it only above api level 22.

You have to take a look at the extra information in the received intent. In my case there are two keys in the extra Bundle of the intent which are useful: “slot” and “subscription”.

Here is the example:

public class IncomingSms extends BroadcastReceiver {

          public void onReceive(Context context, Intent intent) {

                // Retrieves a map of extended data from the intent.
                Bundle bundle = intent.getExtras();

                int slot = bundle.getInt("slot", -1);
                int sub = bundle.getInt("subscription", -1);

                /*
                  Handle the sim info
                */
            }
}

I did not find documentation about the keys in the Bundle so this could be device/manufacturer dependent, i can imagine that the keys are different or something like that. You can verify this by dumping the key set of the bundle:

Set<string> keyset = bundle.keySet();

EDIT:

The information about the phone number of the SIM card may not be available at all since if it is not stored on the SIM card it is likely cannot be queried, but all other information will be available through the SubscriptionManager:

SubscriptionManager manager = SubscriptionManager.from(appContext);
SubscriptionInfo = manager.getActiveSubscriptionInfo(sub);

or

SubscriptionInfo = manager.getActiveSubscriptionInfoForSimSlotIndex(slot);

And there are some useful info in the SubscriptionInfo such as the phone number which one is not guaranteed to be available as I explained above.

I also forgot to mention that the Dual-SIM support in stock android was added from api level 22.

Leave a Comment