从多个模拟设备和电子模拟设备中获取模拟国家ISO。

问题描述 投票:1回答:1

在常规情况下,用户有一个物理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代码。

android telephony country-codes
1个回答
0
投票

你的代码可以得到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());
      }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.