2

INB4: How to find target sim for an incoming call in dual sim android phone? <- does not work, sadly :(

So, I have a phone (A) with to SIM cards:

SIM 1 number: 123

SIM 2 number: 456

and I call from different phone (B: number 789) to 123. On phone A I'm able to detect incoming call and I'm able to get the incoming phone call number (789). What I can't do is detect that the call target was SIM 1 number: 123.

Can someone help me?

SQUIER
  • 21
  • 1

2 Answers2

0

Try this:

public class MyCallReceiver extends BroadcastReceiver {
@Override
    public void onReceive(Context context, Intent intent) {
    String mySim = "";
    mySim = intent.getExtras().getInt("simId", -1);
    if(callingSIM == "0"){
        //SIM1
    }
    else if(callingSIM =="1"){
        //SIM2
    }
    }
}
Ali Has
  • 409
  • 1
  • 6
  • 18
  • As I've mentioned, this does not work. `intent.getExtras()` does not have keys 'simId', 'slot' etc – SQUIER Sep 24 '20 at 12:35
  • You had only mentioned 'slot' – Ali Has Sep 24 '20 at 12:42
  • Maybe you can turn the intent object into JSON, print them out and then see what specifications is there about SIM. – Ali Has Sep 24 '20 at 12:45
  • it's just `state` and `incoming_number` – SQUIER Sep 24 '20 at 13:16
  • I did a search and nothing came up. Besides if the intent includes nothing about the SIM card whole method is no good. Although I think you can do a workaround: When receiving a call from one Sim, another one goes offline (always? I don't know for all phones), use `TelephonyManager` to get both SIM states and check which one is active. – Ali Has Sep 24 '20 at 14:56
0

Ok, I've finally manage to do this, but not directly. I'm getting all information I need from call history.

SQUIER
  • 21
  • 1