Call from second sim

前端 未结 3 802
悲哀的现实
悲哀的现实 2020-11-27 13:30

I have a dual sim android phone. I am using this code to make a call:

private void callBack(String phone, Context context) {
        Intent callIntent = new          


        
相关标签:
3条回答
  • 2020-11-27 13:53
        final Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumberOrUssd));
        final int simSlotIndex = 1; //Second sim slot
    
        try {
            final Method getSubIdMethod = SubscriptionManager.class.getDeclaredMethod("getSubId", int.class);
            getSubIdMethod.setAccessible(true);
            final long subIdForSlot = ((long[]) getSubIdMethod.invoke(SubscriptionManager.class, simSlotIndex))[0];
    
            final ComponentName componentName = new ComponentName("com.android.phone", "com.android.services.telephony.TelephonyConnectionService");
            final PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(componentName, String.valueOf(subIdForSlot));
            intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", phoneAccountHandle);
        } catch (Exception e) {
            e.printStackTrace();
        }
    
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    

    Work on dual-sim Asus Fonepad 7 Android 5.0

    0 讨论(0)
  • 2020-11-27 14:03

    This seems to work on a large range of dual sim devices as Motorola, Micromax, HTC, Samsung

    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, In Samsung S duos this works just fine.

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

    OR

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

    unfortunately for these things we have to get into hit/trial mode as no official documentation is there for dual-sim support.

    0 讨论(0)
  • 2020-11-27 14:10

    Android does not provide APIs to support dual SIM devices. SIM Card related APIs of Android only support default SIM Card(usually SIM #1). It is hardware implementation to support dual SIM on Android, therefore device manufacturer have to implement their own APIs or customize the source code to support their hardware component. You can contact to device manufacturer for dual SIM supporting SDK.

    0 讨论(0)
提交回复
热议问题