Detecting target SimCard of incoming call in Multi-Sim devices

Officially, the only documented value provided by the intent is the phone number.

Some constructors add other values like sim slot number in the intent, but this is not mandatory. This is why there are so many slot keys names possible, like those presented in post 3, each constructor adding his own implementation.

It's also possible some constructor didn't add this value in some models, and that's certainly the case on your model. There is no way of finding this value if the constructor don't deliver it.


If you have done like this it should work. make sure your testing device runs on Android 5.1 or above. dual sim support is added in v 5.1 (Check here)

public class IncomingCallInterceptor extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
    String callingSIM = "";
    Bundle bundle = intent.getExtras();
    callingSIM = String.valueOf(bundle.getInt("simId", -1));

    if(callingSIM.equals("0")){
           // Incoming call from SIM1
        } else if(callingSIM.equals("1")){
           // Incoming call from SIM2
        }
    }
}

Make sure you added the below permission in manifest

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

NOTE :

These values need not to come all the time. network provider support is required .Please read the documentation here

Carrier id of the current subscription. Return UNKNOWN_CARRIER_ID if the subscription is unavailable or the carrier cannot be identified.