gpt4 book ai didi

android - 如何像 truecaller 一样在 android 中使用特定的 sim 卡进行通话?

转载 作者:行者123 更新时间:2023-12-04 23:58:13 25 4
gpt4 key购买 nike

Intent callIntent = new Intent(Intent.ACTION_CALL)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
callIntent.setData(Uri.parse("tel:" + phone));
context.startActivity(callIntent);
callIntent.putExtra("com.android.phone.extra.slot", 0); //For sim 1
and
callIntent.putExtra("com.android.phone.extra.slot", 1); //For sim 2
startActivity(callIntent);

我想在双卡手机中选择 SIM 卡并使用所选 SIM 卡调用电话,就像真正的来电者一样。现在它总是打开默认对话框。如果有人有解决方案,请帮助我。

最佳答案

下面是双卡通话的代码:

private List<PhoneAccountHandle> phoneAccountHandleList;
int item =0;// 0 for sim1 & 1 for sim2
private final static String simSlotName[] = {
"extra_asus_dial_use_dualsim",
"com.android.phone.extra.slot",
"slot",
"simslot",
"sim_slot",
"subscription",
"Subscription",
"phone",
"com.android.phone.DialingMode",
"simSlot",
"slot_id",
"simId",
"simnum",
"phone_type",
"slotId",
"slotIdx"
};


TelecomManager telecomManager = (TelecomManager)this.getSystemService(Context.TELECOM_SERVICE);
phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
Intent intent = new Intent(Intent.ACTION_CALL).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("tel:" + number));
intent.putExtra("com.android.phone.force.slot", true);
intent.putExtra("Cdma_Supp", true);
if (item == 0) {//for sim1
for (String s : simSlotName){
intent.putExtra(s, 0); //0 or 1 according to sim.......
}
if (phoneAccountHandleList != null && phoneAccountHandleList.size() > 0)
{
intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE",
phoneAccountHandleList.get(0));
}
} else {//for sim2
for (String s : simSlotName) {
intent.putExtra(s, 1); //0 or 1 according to sim.......
}
if (phoneAccountHandleList != null && phoneAccountHandleList.size() > 1){
intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE",
phoneAccountHandleList.get(1));
}
}
startActivity(intent);

关于android - 如何像 truecaller 一样在 android 中使用特定的 sim 卡进行通话?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44247691/

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