Call through specified SIM from android-ThrowExceptions

Exception or error:

I am wondering about the possibility of making a phone call from android through a selected SIM on a dual SIM android devices. Is it possible to select a particular SIM to call through programmatically?

How to solve:

The Android SDK doesn’t provide an APIs to control the SIM being used on dual SIM mobiles. In fact, Android doesn’t even really support dual SIM phones. All dual SIM devices are modified extensively by the manufacturers.

You cannot control the SIM through the Android SDK. If any OEM provides such an API for their devices, I am not aware of it, but you can try asking the manufacturer of your dual SIM device directly is such an API exists on their device.

###

Use ACTION_DIAL to let people select their SIM.

###

private void callBack(String phone, Context context) {
    Intent intent = new Intent(Intent.ACTION_CALL).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    //check wheather it is dual sim or not then

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

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

    intent.setData(Uri.parse("tel:" + phone));
    context.startActivity(intent);
}

Check it is dual sim or not,
go through the bellow link

Android : Check whether the phone is dual SIM

###

If the phone is dual sim and you want to make call from sim2 then use 1 if you want to use sim1 then use 0 in intent.putextra

 Intent intentcall = new Intent(Intent.ACTION_CALL);

 intentcall.putExtra("simSlot", 1);
 intentcall.setData(Uri.parse("tel:"+dialNumber));
 startActivity(intentcall);

Leave a Reply

Your email address will not be published. Required fields are marked *