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卡进行调用,如真正的来电者。现在它总是打开默认对话框。 如果有人有解决方案,请帮助我。
答案 0 :(得分:1)
以下是双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);