8

I have an Android phone with 2 SIM card and I want to detect the target of the incoming call — is it for SIM 1 or for SIM 2. Is it possible to get the target number from call info?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Jebasuthan
  • 5,538
  • 6
  • 35
  • 55

3 Answers3

2

Finally I got the solution using this code. Hope it should helpful for everyone who wants to handle Dual SIM phones. Its working fine for me.

Please add below codes in your BroadcastReceiver class:

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
    }
    }
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Jebasuthan
  • 5,538
  • 6
  • 35
  • 55
  • @MehulJoisar, Thanks for your Info. I tested in XOLO device. Its working fine in latest duel SIM cards. Its also not working in My karbonn device. So this get the incoming call SIM is not well documented in android. But i tried it works using this code bundle.getInt("simId"). But i found this is not working some devices. So now i am trying to find good consistent solution. If you have better solutions please share it to us. Thanks – Jebasuthan Feb 26 '14 at 13:48
  • @Jeba, Thanks it works fine in Android 4.2.2. You saved my time. Thanks Jeba. –  Mar 13 '14 at 13:48
  • 1
    @Jeba This is not working. Do you have any other solution which will work in all android dual sim devices ? – Manish Agrawal Oct 09 '15 at 07:19
  • It is possible to get this information from callog history? – Naimish B. Makwana Dec 28 '15 at 09:47
  • We are getting only these values in bundle object: [{incoming_number=+919880594424, state=RINGING}] – Bhagya Oct 26 '16 at 11:49
  • 1
    @jeba it's not working in MI 3s 6.0 device, getting simid = -1 – Gundu Bandgar Jun 30 '17 at 11:57
1
add below codes in your BroadcastReceiver class.

public class IncomingCallInterceptorReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String callingFromSIM = "";
Bundle bundle = intent.getExtras();
callingFromSIM =String.valueOf(bundle.getInt("simId", -1));
if(callingFromSIM == "0"){

    // Incoming call from SIM1 Card

}
else if(callingFromSIM =="1"){

    // Incoming call from SIM2 Card 

}

}

}
Vaishali Sutariya
  • 5,093
  • 30
  • 32
-1
Bundle bundle = intent.getExtras();
    String state = bundle.getString(TelephonyManager.EXTRA_STATE);
    if (state != null){
        callFromSecondSimNo = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
    }

this will give incoming number, whatever set is dual sim or single.

ashique
  • 39
  • 6