0

I'm trying to get sim card details for sim 1 and sim 2 in a Samsung dual phone (Samsung Gt-S6802) , I am able to get details for sim 1 but for sim 2 I get a null value.

I'm using Java reflection method to get both Sim Serial numbers.

I used this tutorial Android : Check whether the phone is dual SIM

Kindly if you know any work around for this let me know.

Thanks

Community
  • 1
  • 1
Rayyidh
  • 21
  • 4
  • `http://www.yogeshblogspot.com/getting-phone-numberimei-number-and-sim-card-id-in-android/` this may help you – Hybrid Developer May 28 '14 at 08:14
  • Does the two kind of card is the same and they can work together? I know there are some problems when getting a sim serival number of CDMA card. There is a link of(in Chinese) http://www.cnblogs.com/xiaowenji/archive/2011/01/11/1933087.html – twlkyao May 28 '14 at 08:15
  • @ДмитрийИвановичМенделеев the link you sent me doesn't work for dual sim phones , but thanks for sharing the link – Rayyidh May 28 '14 at 08:20
  • @twlkyao I tried testing with a different Samsung dual phone ,with android version 4.0.3 it works, but for this particular device I am using it doesn't work it has android version 2.3 it returns null for sim 2 details. – Rayyidh May 28 '14 at 08:23

1 Answers1

1

In case someone is still interested in knowing the answer, for API >= 22 only

// you may ignore TelephonyManager if you don't want to get the IMEI
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

SubscriptionManager subscriptionManager = SubscriptionManager.from(getApplicationContext());
List<SubscriptionInfo> subsList = subscriptionManager.getActiveSubscriptionInfoList();

for (SubscriptionInfo subscriptionInfo : subsList ) {
    // get IMEI
    int simSlotIndex = subscriptionInfo.getSimSlotIndex();
    String imei = telephonyManager.getImei(simSlotIndex);

    // get serial number
    String serialNumber = subscriptionInfo.getIccId();

    // get line number
    String lineNumber = subscriptionInfo.getNumber();
}
Da_Pz
  • 698
  • 5
  • 13