ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android – 在双SIM卡设备中使用指定的SIM拨打电话

2019-09-26 02:36:42  阅读:729  来源: 互联网

标签:telephonymanager android android-intent


过去几天我一直在寻找这个,我开始知道:

“开箱即用的Android不支持双SIM卡.这是制造商的自定义修改,并且没有公共API来控制它.”

下面的链接提供了一个解决方案,但它不能在我的手机三星Galaxy S4 Mini上工作.

Call from second sim

我也发现了这个链接,我发现它非常有用.

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

现在我知道使用下面的代码,我可能有幸有机会让它工作:

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卡时,我有四个选项:

>当前网络
>总是问
> SIM 1
> SIM 2

当我选择“始终询问”选项时,在拨打电话之前,我总是被要求选择一个显示在对话框中的SIM卡来拨打电话.我的问题是我可以在我的应用程序中利用这个东西,我按下按钮拨打电话,但它总是问我,当我选择Ask Always选项时它的方式相同.

对不起,我把这个问题写得很冗长,但我觉得它需要它.请提前帮助和非常感谢.

编辑:

每次按下任何按钮(类似于“设置”中的“始终询问”选项)时,如何实现此目的:

解决方法:

码:

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);

标签:telephonymanager,android,android-intent
来源: https://codeday.me/bug/20190926/1818359.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有