Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 06:44, 30 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Getting Mobile country code (MCC) in Java ME

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: prssupe (09 May 2011)
Last edited: hamishwillee (30 Jul 2013)

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.

This page was last modified on 30 July 2013, at 06:44.
120 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×