How can we check multiple sim in Android Device programmatically? And how can we send an SMS from a specific sim (Sim 1 or Sim 2)?
Asked
Active
Viewed 739 times
1 Answers
1
Use TelephonyManager You would first start by querying the SimState for each individual sim slot by using getSimState(int slotIndex) ie:
int simStateMain = telMgr.getSimState(0);
int simStateSecond = telMgr.getSimState(1);
Then once you figure out which SimCard you want your code would look somewhat like this:
TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int simState = telMgr.getSimState();
switch (simState) {
case TelephonyManager.SIM_STATE_ABSENT:
// do something
break;
case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
// do something
break;
case TelephonyManager.SIM_STATE_PIN_REQUIRED:
// do something
break;
case TelephonyManager.SIM_STATE_PUK_REQUIRED:
// do something
break;
case TelephonyManager.SIM_STATE_READY:
// do something
break;
case TelephonyManager.SIM_STATE_UNKNOWN:
// do something
break;
}
Make sure you're dealing with a GSM phone first so you can actually get at the SIM card though. Note: There are many ways to do this. Could even use a boolean.

Mitchell Monarch
- 117
- 7