【问题标题】:Getting the MCC and MNC for the operator on blackberry在黑莓上为运营商获取 MCC 和 MNC
【发布时间】:2013-04-10 16:48:21
【问题描述】:

我正在尝试为黑莓设备获取 MCC 和 MNC。我正在使用此代码:

int code = RadioInfo.getCurrentNetworkIndex();
int mcc = RadioInfo.getMCC(code);
int mnc = RadioInfo.getMNC(code);
String mccS = Integer.toString(mcc);
String mncS = Integer.toString(mnc);

我正在获取值,字节在互联网上搜索正确的值时,我发现 MCC 和 MNC 与我在此代码中获得的不同。例如对于黎巴嫩的运营商 alfa,我应该获得:

Mcc = 415 和 MNC = 1

我正在获取:

Mcc = 1045 和 MNC = 1

为什么会这样?这是获得 MCC 和 MNC 的正确方法吗?提前致谢

【问题讨论】:

    标签: blackberry


    【解决方案1】:

    您通过使用

    获得 mcc
    String mcc = Integer.toHexString(RadioInfo.getMCC(RadioInfo.getCurrentNetworkIndex()));
    

    【讨论】:

    • 我是否需要使用类似的 Integer.toHexString(GPRSInfo.getMCC()) 或 GPRSInfo.getMCC() 才能工作。请告诉我。
    【解决方案2】:

    根据我的经验,它在 BB 上相当混乱。基于跨不同网络和设备的实验,我们使用

    // manual says MCCs can be identified as either 260 or 26F; actually for us it is decimal so we convert it to hexa
    // this replaceAll "f" stuff is strange, but seems to work: MNC==1F becomes 1 which nicely matches RadioInfo.getMNC(RadioInfo.getCurrentNetworkIndex());
    int mcc =  Integer.parseInt(TextUtils.replaceAll(Integer.toHexString(GPRSInfo.getCellInfo().getMCC()),"f", ""));  
    

    【讨论】:

      【解决方案3】:

      你需要转换数字。

      MNC 和 MCC 将以十进制数字形式返回,而 MCC 和 MNC 将以十六进制数字形式列出。例如,在 AT&T® 移动网络上运行的 BlackBerry 智能手机将返回 MCC=784(十六进制 310)和 MNC=896(十六进制 380)。

      http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/1467358/How_To_-_Determine_the_MCC_and_MNC_of_the_current_network.html?nodeid=1467359&vernum=0

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-07
        • 1970-01-01
        相关资源
        最近更新 更多