I'm trying to retrieve the SIM serial number (also known as ICCID) in Android 13 using the TelephonyManager and SubscriptionManager, but I'm encountering some issues. Here's what I've tried:
- I've declared the necessary permissions in my AndroidManifest.xml file:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
2.I'm using the following code to get the SIM serial number:
TelephonyManager telephonyManager = getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
SubscriptionManager subscriptionManager = getSystemService(SubscriptionManager.class);
List<SubscriptionInfo> subscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
if (subscriptionInfoList != null) {
for (SubscriptionInfo subscriptionInfo : subscriptionInfoList) {
String simSerialNumber = subscriptionInfo.getIccId();
// Handle the SIM serial number here
}
}
}
However, this code doesn't seem to be working in Android 13. It used to work in earlier versions, but it's not retrieving the SIM serial number.
Are there any alternative methods to retrieve the SIM serial number in Android 13? Any help or guidance on this issue would be greatly appreciated. Thank you!
Most of the times it gives empty string only: this is what official document says Link