zaswq12
zaswq12

Reputation: 11

Choosing SIM to make a call

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.

Upvotes: 0

Views: 560

Answers (1)

zaswq12
zaswq12

Reputation: 11

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

Upvotes: 1

Related Questions