我知道我可以通过该接收器检测到新的拨出呼叫:
<receiver android:name=".NewOutgoingCallReceiver">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
在 OnReceive 方法中,我想知道哪个 sim 进行此调用?
public class NewOutgoingCallReceiver extends BroadcastReceiver
{
@Override
public void onReceive( Context context, Intent intent )
{
// here i want to check which sim is making that new call
}
}
广播接收器收到的意图应该在捆绑包中包含一些额外信息,其中之一是“插槽” - 意思是 SIM 插槽。
您可以在上面的示例中得到这个,如下所示 - 这适用于 API 22 及更高版本:
public class NewOutgoingCallReceiver extends BroadcastReceiver
{
@Override
public void onReceive( Context context, Intent intent )
{
//check which sim is making that new call
String callSlot = "";
Bundle bundle = intent.getExtras();
callSlot =String.valueOf(bundle.getInt("slot", -1));
if(callSlot == "0"){
//Call is from SIM slot0
} else if(callSlot =="1"){
//Call is from SIM slot 1
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)