Android如何指定SIM卡拨号
2020-06-10 本文已影响0人
夏无雪
废话不多说,直接上代码
public static final String[] DUAL_SIM_TYPES = {"subscription",
"Subscription",
"com.android.phone.extra.slot",
"phone",
"com.android.phone.DialingMode",
"simId",
"simnum",
"phone_type",
"simSlot"};
拨号逻辑
/**
* 拨打电话(拨号权限自行处理)
* @param phoneNum :目标手机号
* @param simIndex :sim卡的位置 0代表sim卡1,1代表sim卡2
*/
private void callPhone(String phoneNum,int simIndex) {
Intent callIntent = new Intent(Intent.ACTION_CALL).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
callIntent.setData(Uri.parse(phoneNum));
for (String dualSimType : DUAL_SIM_TYPES) {
callIntent.putExtra(dualSimType, simIndex);
}
this.startActivity(callIntent);
}