Android 使用任何Sim卡拨打电话

Android 使用任何Sim卡拨打电话,android,Android,我正在开发一款Android应用程序,它根据if条件从sim卡拨打电话。如果满足一个条件,应用程序必须从Sim 1拨打电话;如果满足所有其他条件,应用程序必须从Sim 2拨打电话,无论默认Sim是什么。我浏览了这个论坛上的许多帖子,但没有找到任何有用的东西 我目前正在使用以下代码运行我的应用程序 // (0 for first sim and 1 for 2nd sim) callIntent.putExtra("com.android.phone.extra.slot", 1); 我还尝试

我正在开发一款Android应用程序,它根据
if
条件从sim卡拨打电话。如果满足一个条件,应用程序必须从Sim 1拨打电话;如果满足所有其他条件,应用程序必须从Sim 2拨打电话,无论默认Sim是什么。我浏览了这个论坛上的许多帖子,但没有找到任何有用的东西

我目前正在使用以下代码运行我的应用程序

// (0 for first sim and 1 for 2nd sim)
callIntent.putExtra("com.android.phone.extra.slot", 1); 
我还尝试了另外一种方法

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

callIntent.putExtra("simSlotName", 1);
这两种方法都不起作用。请帮我完成它

完整的代码在这里

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

Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "any number"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("com.android.phone.force.slot", true);
intent.putExtra("Cdma_Supp", true);
//Add all slots here, according to device.. (different device require different key so put all together)
for (String s : simSlotName)
    intent.putExtra(s, 0); //0 or 1 according to sim.......

//works only for API >= 21
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", (Parcelable) " here You have to get phone account handle list by using telecom manger for both sims:- using this method getCallCapablePhoneAccounts()");

context.startActivity(intent);

你调查过这件事吗?我做了,但没有用。你找到任何解决方案了吗?请告诉我。上面的代码在很多手机上都很好用。但不适用于维梧V11 Pro 1804和维梧Y81。你在这个列表中找到任何新的密钥集了吗?我在包裹上发现了一个错误,你能告诉我如何使用getCallCapablePhoneAccounts()而不是仅仅给出一个描述吗。