android - 副 SIM 卡的 MNC 和 MCC

标签 android telephonymanager

我知道使用 TelephonyManager 我们可以获得网络提供商的 MNC 和 MCC,

TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tel.getNetworkOperator();

if (networkOperator != null) {
    int mcc = Integer.parseInt(networkOperator.substring(0, 3));
    int mnc = Integer.parseInt(networkOperator.substring(3));
}

但我只能获取主 sim 的 MNC 和 MCC 数据。我想知道有没有办法在 android 中获取设备的辅助 sim 卡的 mnc、mcc、lac 和 cellid。

最佳答案

在API 22之前,很难达到你想要的。

我相信在 API 22 之前,Android 最初不支持双卡双待。因此,每个移动供应商都应该有自己的实现。也许,您应该获取他们的 API/SDK 并将它们包含到您的项目中。只有这样,您才能访问他们的 API。

从 API22 开始,我认为你可以使用 SubscriptionManager

    int mccSlot1 = -1;
    int mccSlot2 = -1;
    int mncSlot1 = -1;
    int mncSlot2 = -1;

    SubscriptionManager subManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);

    if(subManager.getActiveSubscriptionInfoCount() >= 1) {
        mccSlot1 = subManager.getActiveSubscriptionInfo(0).getMcc();
        mncSlot1 = subManager.getActiveSubscriptionInfo(0).getMnc();
    }

    if(subManager.getActiveSubscriptionInfoCount() >= 2) {
        mccSlot2 = subManager.getActiveSubscriptionInfo(1).getMcc();
        mncSlot2 = subManager.getActiveSubscriptionInfo(1).getMnc();
    }

问题 https://stackoverflow.com/a/32871156/4860513提到相同的 Android 限制。所以,我真的相信在 API22 之前使用纯 Android SDK 是不可能实现的。

关于android - 副 SIM 卡的 MNC 和 MCC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35449117/

相关文章:

android - 可扩展列表查看团体和 child 的不同图像

android - 打开应用程序时阻止来电

android - 如何在Android中检索SIM卡IMSI?

android - Kotlin中的音乐URI空指针异常

android - 如何使用 sharedview 模型 koin android 注入(inject)具有作用域的 View 模型

android - PhoneStateListener 中的拨出调用检测

android - 如何获取安卓手机的电话号码?

android - 双 SIM 卡中的 getAllCellInfo

java - 从 Eclipse 迁移到 Android Studio 问题

android - 如何将字符串项添加到列表?