-1

I am using TelephonyManager to get sim's serial number, but I want to get serial number of both the sims if the device is dual sim. I know I can do this using this answer but that method is too complex. So the question is that is there any simpler method? My device's Android Version is KitKat (API-19).

Community
  • 1
  • 1
Raees Khan
  • 371
  • 1
  • 5
  • 20

1 Answers1

1

Since you're asking for help, I'll reformulate what's in this answer.

  1. Create a new class public final class TelephonyInfo.
  2. Copy/Past the code found in this answer.
  3. Get an instance of the TelephonyInfo class and use it.

How to get an instance?

// From an Activity, a Service...
TelephonyInfo telephonyInfo = TelephonyInfo.getInstance(this);

How to get both IMSIs?

// Check if the phone supports two SIM cards
if (telephonyInfo.isDualSIM()) {
    // Check if the first SIM is ready
    if (telephonyInfo.isSIM1Ready()) {
        String imsiSIM1 = telephonyInfo.getImsiSIM1();
    }
    // Check if the second SIM is ready
    if (telephonyInfo.isSIM2Ready()) {
        String imsiSIM2 = telephonyInfo.getImsiSIM2();
    }
}

Check the original answer, It's pretty well written.