Is the target phone number detected on an incoming call - is it for SIM 1 or for SIM 2?

I have an Android phone with 2 SIM cards, and I want to determine the purpose of the incoming call - is it for SIM 1 or for SIM 2. Is it possible to get the target number from the call information?

+6
source share
3 answers

Finally, I got a solution using this code. I hope this will be useful for anyone who wants to handle dual SIM phones. His work is wonderful for me.

Please add the codes below to 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 } } } 
+3
source
 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 } } } 
+1
source
 Bundle bundle = intent.getExtras(); String state = bundle.getString(TelephonyManager.EXTRA_STATE); if (state != null){ callFromSecondSimNo = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER); } 

this will give an incoming number, no matter which dial is double sim or single.

-1
source

All Articles