在常规情况下,用户有一个物理SIM是他的设备,我会得到国家文化代码由以下代码。
TelephonyManager manager = (TelephonyManager) cxt.getSystemService(Context.TELEPHONY_SERVICE);
//getNetworkCountryIso
if (manager != null && manager.getSimCountryIso() != null) {
return manager.getSimCountryIso().toLowerCase();
}
但当设备中有2个sim时,上述代码会发生什么变化呢? 当设备持有e-sim而不是物理sim时,我将如何获得国家ISO代码。
你的代码可以得到SIM卡的国家ISO,该SIM卡的槽位在1,不会关心其他SIM卡槽位。
为了读取所有的SIM卡槽位,可以通过调用 SubscriptionManager.getSubscriptionId() 的数组,将返回一个 subscription ID's
我们知道安卓多卡支持完全是基于厂商,在谷歌安卓系统中,在双多卡的情况下,你可以更新你的手机,你的手机,你的手机,你的手机,你的手机,你的手机。TelephonyManager
如下图所示
subIds[] = SubscriptionManager.getSubscriptionIds(slotInex) //Pass slot index ex: 0,1 etc
for(int i=0;i<subIds.lenth();i++){
if (SubscriptionManager.isActiveSubscriptionId(subIds[i])){
TelephonyManager manager = telephonyManager.createForSubscriptionId(subIds[i]);
if (manager != null && manager.getSimCountryIso() != null) {
System.out.println(manager.getSimCountryIso().toLowerCase());
}
}
}