0

This is my code, if I call with 123 I want it such that sim number 1 is used, else use sim number 2, but it is not working:

String number="123";

        if(number.equals("123")){
             Intent callIntent = new Intent(Intent.ACTION_CALL)
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    callIntent.setData(Uri.parse("tel:"+number));

    callIntent.putExtra("com.android.phone.extra.slot", 0); //For sim 1
     startActivity(callIntent); 
        } else {
             Intent callIntent = new Intent(Intent.ACTION_CALL)
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            callIntent.setData(Uri.parse("tel:"+number));

    callIntent.putExtra("com.android.phone.extra.slot", 1); //For sim2
     startActivity(callIntent); 
thor
  • 21,418
  • 31
  • 87
  • 173
alva
  • 9
  • 6
  • First of all, you should compare numbers with '=='. Secondly, could you please be more specific? Is there any error message? – Tony Danilov Apr 23 '16 at 20:28
  • i use equals because data type in callintent.setdata use string not int,double,float etc, no eror message but not working because always ask choose simcard and i want automatically if 123 use simcard 1 and else use simcard 2 – alva Apr 23 '16 at 20:38
  • Unless there is other code, you appear to be setting number to 123 (first line of the given code ie `String number="123";`), as such number will always be 123. – MikeT Apr 23 '16 at 22:10
  • my problem is equal to this thread http://stackoverflow.com/questions/25524476/make-call-using-a-specified-sim-in-a-dual-sim-device – alva Apr 24 '16 at 04:34

0 Answers0