Reputation: 2310
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
Upvotes: 3
Views: 2467
Reputation: 3725
you get mcc by using
String mcc = Integer.toHexString(RadioInfo.getMCC(RadioInfo.getCurrentNetworkIndex()));
Upvotes: 7
Reputation: 7572
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", ""));
Upvotes: 3
Reputation: 3065
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).
Upvotes: 2