0

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

Zoe
  • 27,060
  • 21
  • 118
  • 148
Vikas
  • 432
  • 4
  • 17
  • You're asking two different question. Both which are too broad while you did not provide any code nor explained any attempts. Please read https://stackoverflow.com/help/how-to-ask :) – shkschneider Mar 05 '19 at 12:24

1 Answers1

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.