本文介绍了辅助SIM卡的MNC和MCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I know that using TelephonyManager we can get MNC and MCC of our network provider,

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中获取设备的Secondary sim的mnc,mcc,lac和cellid.

But I was able to get MNC and MCC data of only primary sim. I would like to know is there a way to fetch mnc,mcc,lac and cellid's of Secondary sim of a device in android.

推荐答案

在API 22之前,很难实现您想要的.

Before API 22, it will be hard to achieve what you want.

我认为,在API 22之前,Android最初不支持双SIM卡.因此,每个移动设备供应商都应该有自己的实现.也许,您应该获取它们的API/SDK,并将其包含在您的项目中.只有这样,您才可以访问他们的API.

I believe that before API 22, dual SIM was not originally supported by Android. So, each Mobile vendor should have its own implementation. Maybe, you should get their APIs/SDKs and include them to your project. Only this way, you will have access to their APIs.

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

From API22 onward, I think you can use 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限制.因此,我真的相信在使用纯Android SDK的API22之前不可能实现这一目标.

Question https://stackoverflow.com/a/32871156/4860513 mention the same Android Limitation. So, I really believe it is not possible to achieve that before API22 with pure Android SDK.

这篇关于辅助SIM卡的MNC和MCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 14:11