我正在尝试在三星双手机(Samsung Gt-S6802)中获取sim 1和sim 2的sim卡详细信息,我能够获取sim 1的详细信息,但对于sim 2,我得到一个空值。
我正在使用Java反射方法来获取两个Sim序列号。
我使用了本教程Android : Check whether the phone is dual SIM
如果您知道任何解决方法,请告诉我。
谢谢
最佳答案
如果有人仍然想知道答案,仅适用于API> = 22
// 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();
}