Detect target phone number on incoming call is it for SIM 1 or for SIM 2?

后端 未结 3 1034
梦谈多话
梦谈多话 2020-12-29 15:55

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 cal

3条回答
  •  执念已碎
    2020-12-29 16:30

    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 
    
    }
    
    }
    
    }
    

提交回复
热议问题