Getting Mobile country code (MCC) in Java ME
Article Metadata
Compatibility
Article
This article shows how to get the mobile country code (MCC) using J2ME
MOBILE COUNTRY CODE
Mobile country code (MCC) is a unique code assigned for each country, frequently related to the list of Mobile Network Code (MNC), and used to get the list of all country codes. A possible and useful usage of MCC is localization, allowing the programmer to modify your applications look and feel based on country's localization. To use MCC in your application, the device should support Location API for J2ME, described in JSR-179.
The following snippet code provides information about how to retrieve MCC on various J2ME enabled handsets (an expanded example may be found at [1]):
public String getMCC() {
String out = "";
try {
if (out == null || out.equals("null") || out.equals("")) {
out = System.getProperty("phone.mcc");
}
if (out == null || out.equals("null") || out.equals("")) {
if (out == null || out.equals("null") || out.equals("")) {
out = System.getProperty("com.sonyericsson.net.mcc");
}
}
if (out == null || out.equals("null") || out.equals("")) {
out = getIMSI().equals("") ? "" : getIMSI().substring(0, 3);
}
if (out == null || out.equals("null") || out.equals(""))//getMNC()
{
if (out == null || out.equals("null") || out.equals("")) {
out = System.getProperty("mcc");
}
}
} catch (Exception e) {
return out == null ? "" : out;
}
return out == null ? "" : out;
}
public String getIMSI() {
String out = "";
try {
out = System.getProperty("IMSI");
if (out == null || out.equals("null") || out.equals("")) {
out = System.getProperty("phone.imsi");
}
if (out == null || out.equals("null") || out.equals("")) {
out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
}
if (out == null || out.equals("null") || out.equals("")) {
out = System.getProperty("com.nokia.mid.imsi");
}
if (out == null || out.equals("null") || out.equals("")) {
out = System.getProperty("IMSI");
}
if (out == null || out.equals("null") || out.equals("")) {
out = System.getProperty("imsi");
}
} catch (Exception e) {
return out == null ? "" : out;
}
return out == null ? "" : out;
}
If you are interested in the complete set of system properties for Nokia phones, please check the technical study TSJ000306.


Marcelobarrosalmeida - How about adding a complete example ?
How about adding a complete example, showing the list and changing the localization after selection ? This way, the article will become complete and a good reference for localizing programs. Comments about how to use so many different methods for obtaining the MCC/MNC would be fine as well. I can imagine that is related to phone maker but an explanation always helps.marcelobarrosalmeida 12:44, 10 November 2011 (EET)