首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在双SIM设备中使用指定的SIM进行呼叫

问在双SIM设备中使用指定的SIM进行呼叫
EN

Stack Overflow用户
提问于 2014-08-27 10:14:58
回答 3查看 52.1K关注 0票数 22

我在过去的几天里一直在寻找这个问题,并且我了解到:

“Android中不支持双SIM。这是制造商的定制修改,没有公共API来控制它。”

有一个解决方案提供在下面的链接,但它不能在我的手机三星银河S4迷你。

Call from second sim

我也找到了这个链接,我发现了非常有用的信息。

http://www.devlper.com/2010/06/using-android-telephonymanager/

现在我知道了,使用以下代码,我可能有机会幸运地使它正常工作:

代码语言:javascript
复制
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

我不确定,但我有个问题。

在SIM卡管理器部分下的设置中,当我必须为语音呼叫选择首选SIM卡时,我将获得以下四个选项:

  1. 电流网络
  2. 总问
  3. SIM 1
  4. SIM 2

当我选择询问总是选项,然后在打电话之前,我总是被要求选择一个SIM卡,显示在一个对话框中,打电话。我的问题是,我可以利用这个东西在我的应用程序中,我按下一个按钮打电话,但它总是问我一样,当我选择问总是选项。

对不起,我把这个问题弄得很长,但我认为这是必需的。请提前提供帮助并表示感谢。

编辑:

我如何做到这一点,每次我按下任何按钮(类似于询问始终选项在设置):

​

EN

回答 3

Stack Overflow用户

发布于 2016-07-27 06:22:43

代码:

代码语言:javascript
复制
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);
票数 14
EN

Stack Overflow用户

发布于 2017-06-01 04:22:47

代码语言:javascript
复制
TelecomManager telecomManager = (TelecomManager) this.getSystemService(Context.TELECOM_SERVICE);
List<PhoneAccountHandle>    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 (simselected== 0) {   //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 {      1 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);
票数 11
EN

Stack Overflow用户

发布于 2018-03-24 14:45:01

我对这个问题有一个答案,因为我正在寻找这个选项。以下是几个步骤:

  • 首先,您需要的是X位框架和;
  • 安装miui应用程序;
  • 在联系人中添加首选sim选项
票数 -4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25524476

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档