0

这是我的代码,如果我123想要调用它以便1使用 sim 号码,否则使用 sim 号码 2,但它不起作用:

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

0 回答 0