使用双SIM卡设备中的指定SIM卡拨打电话
过去几天来我一直在寻找这个,我知道:
I have been searching for this from past few days and I came to know that:
"Android暂时不支持双SIM卡.这是制造商的自定义修改,并且没有公共API来控制它."
"Dual SIM is not supported in Android out of the box. It is a custom modification by manufacturers, and there is no public API to control it."
下面的链接中提供了一个解决方案,但不适用于我的手机Samsung Galaxy S4 Mini.
There is a solution provided in the below link but its not working on my phone Samsung Galaxy S4 Mini.
我还找到了此链接,该链接非常有用.
I also found this link, which I found very informative.
http://www.devlper.com/2010/06/using -android-telephonymanager/
现在,我知道使用以下代码,我可能有幸能使其正常工作:
Now I know that using the following code, I might have a chance to get lucky to make it working:
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
对此我不确定,但是我有一个问题.
I am not sure about this, but I have a question.
在"SIM卡管理器"部分下的设置"中,当我必须为语音呼叫选择首选的SIM卡时,我有四个选项:
In Settings under the SIM Card Manager section, when I have to choose a preferred SIM card for Voice Call, I get four options:
- 当前网络
- 总是问
- SIM 1
- SIM 2
当我选择始终询问"选项时,在拨打电话之前,总是要求我选择对话框中显示的SIM卡进行通话.我的问题是,我可以在我的应用程序中利用此功能吗?我按此按钮可以拨打电话,但它总是问我选择总是询问"选项时的方式.
When I choose Ask Always option then before making a call I am always asked for choosing a SIM Card, displayed in a Dialog Box, to make the call. My question is can I exploit this thing in my App where I press a button to make a call but it always asks me the same way it does when I chose Ask Always option.
很抱歉,我把这个问题冗长了,但是我认为这是必需的.请提前提供帮助和感谢.
I am sorry, I made this question lengthy, but I think it required it. Please help and big thanks in advance.
每次我按任意按钮时,该如何实现(类似于设置"中的总是询问"选项):
How can I achieve this, everytime I press any button (Kind of similar to Ask Always option in Settings) :
代码:
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);