问题
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 ?
回答1:
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
回答2:
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
}
}
}
来源:https://stackoverflow.com/questions/33017254/how-to-find-target-sim-for-an-incoming-call-in-dual-sim-android-phone