gpt4 book ai didi

java - 我如何检测双卡设备中哪个卡的新拨出电话?

转载 作者:行者123 更新时间:2023-12-02 02:18:44 26 4
gpt4 key购买 nike

我知道我可以通过此接收器检测到新的拨出调用:

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

最佳答案

广播接收器收到的 Intent 应该在 bundle 中包含一些额外信息,其中之一是“插槽” - 意思是 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
}
}
}

关于java - 我如何检测双卡设备中哪个卡的新拨出电话?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48868040/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com