Choosing SIM to make a call

532 Views Asked by At

I'm really interested in working this out.

I'm developing an app which is supposed to make calls, but the problem starts when device has dual SIM. After starting Intent.ACTION_CALL activity a dialog pops up to choose the SIM card, I managed not to open that dialog by putting "NOT_NEED_SIMCARD_SELECTION" extra with value: false. But still I don't know how to force slot I want to use. This should work on API 19.

I found an app Dual SIM Selector where it works perfectly, but I have no idea how they managed it.

1

There are 1 best solutions below

1
On BEST ANSWER

I figured it out with help of reflections. It turns out my device's API was somehow changed and it provides methods like setDefaultSim.

Method setDefaultSim = TelephonyManager.class.getDeclaredMethod("setDefaultSim", Context.class, int.class, int.class);
setDefaultSim.invoke(null, this, 0, slot);