Intent.ACTION_CALL is not working when a pop up window opens to select my account

佐手、 提交于 2019-12-25 13:29:09

问题


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.

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

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

My code:

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

        }
     });

回答1:


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

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

or

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

or

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



回答2:


Simply write these two line of code rest of thee this will automatically done by the system hear you don't worry about single/dual SIM

Intent callIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:"+"999999");
            startActivity(callIntent);
        } 

refer official guide for more detail http://developer.android.com/reference/android/content/Intent.html



来源:https://stackoverflow.com/questions/32614035/intent-action-call-is-not-working-when-a-pop-up-window-opens-to-select-my-accoun

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!