当弹出窗口打开以选择我的帐户时,Intent.ACTION_CALL不起作用 [英] Intent.ACTION_CALL is not working when a pop up window opens to select my account

查看:527
本文介绍了当弹出窗口打开以选择我的帐户时,Intent.ACTION_CALL不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现一个Android应用,该应用将允许用户通过按一个按钮从我的应用中拨打电话来购买商品.在单SIM卡设备中,它运行良好,但是在双SIM卡设备中,当我运行我的应用程序并单击购买按钮"时,会自动打开一个弹出窗口,询问我要使用哪个SIM卡进行拨号(我不必编写此操作的代码,该操作由我的设备自动完成.另外,当我通常使用设备的默认Phone App打电话给朋友时,该弹出窗口会自动打开,询问我要拨打的SIM卡,并选择一个SIM卡开始通话),但在选择SIM卡后使用我的应用的情况下,它将无法正常工作,无法开始拨号.但是它开始拨入单个sim设备.

I am implementing an Android app that will allow users to purchase something by dialing a number from my app pressing a button. In single SIM devices it works nicely, but in dual sim devices, when I run my app and click on the "Purchase Button" a popup window automatically opens to ask me which SIM I want to use to dial (I didn't have to write code for this action, It automatically done by my device. Also when I normally call a friend using the default Phone App of my device this pop up window opens automatically to ask me which Sim I wanna use to dial and after selecting a sim it starts calling), but in case of my app after selecting an SIM , It doesn't work, It doesn't start dialing. But It starts dialing in single sim devices.

我已经正确添加了<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>,我的代码在单个SIM卡设备上也能很好地工作.

I have added <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> correctly and my code works nicely on single SIM devices.

那是什么问题?为什么不能在双Sim设备上使用它?

So what's the problem? Why it's not working on dual Sim devices?

我的代码:

Button button1maina = (Button) findViewById(R.id.Button03);

        button1maina.setOnClickListener(new OnClickListener() {
     @Override
         public void onClick(View v) {

         Intent callIntent = new Intent(Intent.ACTION_CALL);
         callIntent.setData(Uri.parse("tel:" + "*566%23"));;
         startActivity(callIntent);  

        }
     });

推荐答案

您必须指定Simcard才能启动意图活动.首先,通过以下链接检查手机是否为Dual Sim: https://stackoverflow.com/a/17499889/3743245

You must specify the simcard to start the intent activity. First of all, check if the phone is Dual Sim with this link: https://stackoverflow.com/a/17499889/3743245

之后,尝试询问用户他/她将使用哪个simcard并传递如下信息:

After that, try to ask the user which simcard he/she will use and pass that info like this:

intent.putExtra("com.android.phone.extra.slot", 0); //For sim 1

intent.putExtra("com.android.phone.extra.slot", 1); //For sim 2

如果不起作用,请尝试以下操作:

and if doesn't work try this:

intent.putExtra("simSlot", 0); //For sim 1

intent.putExtra("simSlot", 1); //For sim 2

这篇关于当弹出窗口打开以选择我的帐户时,Intent.ACTION_CALL不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆