2

I am creating an android application in which I need to detect the target sim for an incoming call in dual sim phone. The Android API provides the access of only one SIM. I did googling about this but couldn't find the solution, All I found is that we can not detect the target SIM because this is depend upon the device manufactures.

Is there any API available to detect the target SIM ?

Manish Agrawal
  • 541
  • 2
  • 6
  • 22

2 Answers2

0

in lollipop 22+

public class MessageReceiver extends BroadcastReceiver {
@Override
 public void onReceive(Context context, Intent intent) {  
  int slot = Integer.parseInt((String) intent.getExtras().get("slot"));
  if(slot == 0){
    // sim1
  }
  if(slot == 1){
    // sim2
  }
}

}

tested in Lenovo K3 note

Hamidreza Sadegh
  • 2,110
  • 30
  • 33
-1

Try this...

    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 == "0"){
        // Incoming call from SIM1
    }
    else if(callingSIM =="1"){
        // Incoming call from SIM2
    }
    }
}
Mayuri Joshi
  • 162
  • 1
  • 2
  • 12