I need the SIM Serial Number to identify the SIM Card for application. The code is very simple for single SIM phones,
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
sim_ID = telephonyManager.getSimSerialNumber();
However, when I test this on a dual SIM phone it gets weird because I can't be sure if the serial number returned is from Slot 1 or Slot 2. Is there any way to get both sim serial numbers? Or can I, in any way, identify which Sim slot is returning the serial number when the above code is called?
P.S. I don't need IMEI numbers or IMSI numbers. I specifically need the SIM serial number (SSN).
For API level >= 22
It can be obtained using the SubscriptionManager class (added in API level 22, https://developer.android.com/reference/android/telephony/SubscriptionManager)
SubscriptionManager sManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)
SubscriptionInfo infoSim1 = sManager.getActiveSubscriptionInfoForSimSlotIndex(0);
SubscriptionInfo infoSim2 = sManager.getActiveSubscriptionInfoForSimSlotIndex(1);
For API level <= 21
For single SIM: TelephonyManager.getSimSerialNumber()
For dual sim: It depends on the manufacturer of the phone.
There is no defined way for getting Sim Serial Number
for dual sim below API level 21.