Make call using a specified SIM in a Dual SIM Device

前端 未结 3 2081
独厮守ぢ
独厮守ぢ 2020-12-08 15:27

I have been searching for this from past few days and I came to know that:

\"Dual SIM is not supported in Android out of the box. It is a custom modification by manu

相关标签:
3条回答
  • 2020-12-08 16:08
    TelecomManager telecomManager = (TelecomManager) this.getSystemService(Context.TELECOM_SERVICE);
    List<PhoneAccountHandle>    phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
    
    
     Intent intent = new Intent(Intent.ACTION_CALL).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setData(Uri.parse("tel:" + number));
            intent.putExtra("com.android.phone.force.slot", true);
            intent.putExtra("Cdma_Supp", true);
            if (simselected== 0) {   //0 for sim1
                for (String s : simSlotName)
                    intent.putExtra(s, 0); //0 or 1 according to sim.......
    
                if (phoneAccountHandleList != null && phoneAccountHandleList.size() > 0)
                    intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", phoneAccountHandleList.get(0));
    
            } else {      1 for sim2
                for (String s : simSlotName)
                    intent.putExtra(s, 1); //0 or 1 according to sim.......
    
                if (phoneAccountHandleList != null && phoneAccountHandleList.size() > 1)
                    intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", phoneAccountHandleList.get(1));
    
            }
            startActivity(intent);
    
    0 讨论(0)
  • 2020-12-08 16:30

    I have an answer for this problem as I was looking for this option. Here are the steps:

    • first you need xposed framework and;
    • install miui application and;
    • add preferred sim option in contact
    0 讨论(0)
  • 2020-12-08 16:32

    Code:

    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);
    
    0 讨论(0)
提交回复
热议问题