Getting the MCC and MNC for the operator on blackberry
I am trying to get the MCC and 开发者_高级运维MNC for the blackberry device. I am using this code:
int code = RadioInfo.getCurrentNetworkIndex();
int mcc = RadioInfo.getMCC(code);
int mnc = RadioInfo.getMNC(code);
String mccS = Integer.toString(mcc);
String mncS = Integer.toString(mnc);
I am getting values, byt when searching for the right values on the internet, I found that the MCC and MNC differ from the ones I obtained in this code. For example for the operator alfa in lebanon, I should obtain:
Mcc = 415 and MNC = 1
I am obtaining:
Mcc = 1045 and MNC = 1
Why Is that happening? Is this the right way to get the MCC and MNC? Thanks in advance
you get mcc by using
String mcc = Integer.toHexString(RadioInfo.getMCC(RadioInfo.getCurrentNetworkIndex()));
In my experience it's quite messy on BB. Based on experiments accross different networks and devices, we use
// 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", ""));
You need to convert the number.
The MNC and MCC will be returned as decimal numbers, whereas MCCs and MNCs will be listed as hexadecimal numbers. For example, a BlackBerry smartphone operating on the AT&T® mobile network will return MCC=784 (hex 310) and MNC=896 (hex 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
精彩评论