如何在安卓手机上像真实来电一样使用指定的SIM卡进行通话?

3
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进行通话,就像Truecaller一样。现在它总是打开默认对话框。如果有人有解决方案,请帮忙。

1个回答

3
以下是双卡通话的代码:
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);

你有最新的密钥列表吗?这个设置在Vivo手机上不起作用。例如:Vivo V11 Pro 1804,y81...使用Android 10。 - Aram

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接