在黑莓手机上为操作员获取MCC和MNC

时间:2011-08-17 08:48:31

标签: blackberry

我正在尝试为黑莓设备获取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与我在此代码中获得的值不同。例如,对于黎巴嫩的运营商阿尔法,我应该获得:

Mcc = 415且MNC = 1

我正在获得:

Mcc = 1045且MNC = 1

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

3 个答案:

答案 0 :(得分:7)

使用

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

答案 1 :(得分:3)

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

// 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", ""));  

答案 2 :(得分:2)

您需要转换数字。

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