Monday, April 7, 2008

Getting the IMEI Number of a Mobiles Using J2ME

International Mobile Equipment Identity (IMEI) is used to identify valid devices connected to GSM and UMTS network. This number can be accessed from a mobile phone by dialing *#06# on the keypad. IMEI is commonly use by software developers as part of software protection scheme to prevent it from being pirated. JavaME developers however suffers from a drawback because MIDP/CLDC specification does not include an API to obtain IMEI from mobile devices. However there are few phone manufacturers included this functionality through System.getPropery() calls. Here's how to get IMEI number from mobile devices of different manufacturers

Manufacturer Argument
Nokia Mobiles System.getProperty("com.nokia.mid.imei”);
Sony-Ericsson Mobiles System.getProperty("com.sonyericsson.imei");
Motorola Mobile System.getProperty("IMEI");
Motorola Mobile System.getProperty("com.motorola.IMEI");
Samsung Mobiles System.getProperty("com.samsung.imei");
Siemens Mobiles System.getProperty("com.siemens.imei");

System properties

The table below defines the generic system properties used by the S60 platform.

Generic system properties

System property Description Value
microedition.platform Name of the host platform or device. Defined in CLDC 1.0 and CLDC 1.1.
microedition.encoding Character encoding. Always returns ISO-8859-1.
microedition.configuration Name and version of the supported configuration value is either “CLDC-1.0” or “CLDC-1.1”, depending on which configuration is implemented. Defined in CLDC 1.0 and CLDC 1.1.
microedition.profiles Names of the supported profile as specified in the MIDP 2.1 API specification. Devices that implement other profiles will also return names of those profiles. Defined in MIDP 2.1 (java.lang package documentation).
microedition.locale* The value is determined according to the language settings of the device. Defined in MIDP 2.1 (java.lang package documentation).
microedition.commports
Defined in MIDP 2.1 javax.microedition.io.CommConnection.
microedition.hostname Returns the local host localhost
microedition.jtwi.version
Defined in Java Technology for the Wireless Industry API specification, version 1.0.

(* - The set of locales supported by the device depends on the languages and region.)

The table below defines the S60 specific system properties used by S60 platform. These system properties are available to the application by calling method java.lang.System.getProperty

Nokia system properties

The table below defines the S60 specific system properties used by S60 platform. These system properties are available to the application by calling method java.lang.System.getProperty

System property Description Value
com.nokia.network.access Returns the networking access point type. pd.GSM - Packet data in GSM network

pd.EDGE - Packet data in EDGE network pd.3G - Packet data in 3G network csd - Circuit switched data, for example GSM CSD/HSCSD data call bt_pan - Bluetooth PAN network wlan - Wireless network, for example 802.11b, 802.11G or WiMaX hsdpa - High speed downlink packet access for 3G networks na - Not applicable, the implementation can’t determine the type

com.nokia.mid.dateformat The preferred date format indicated as a string pattern, which is formatted according to the rules defined in Java 2, Standard Edition, version 1.4.1, java.text.SimpleDateFormat class documentation for date patterns.

Only subset of SimpleDateFormat defined pattern letters are used in this system property.


com.nokia.mid.timeformat The preferred time format indicated as a string pattern, which is formatted according to the rules defined in Java Standard Edition, version 1.4.1, java.text.SimpleDateFormat class documentation for time patterns.

Only subset of SimpleDateFormat defined pattern letters are used in this system property.

hh:mm a
com.nokia.memoryramfree This can be used to query the available RAM in the operating system.

This is a more realistic estimate of available RAM on the device than what is returned by Runtime.getRuntime().freeMemory(), which returns only free memory in the Java virtual machine. Note: This property is not available on all S60 3rd Edition devices.


com.nokia.mid.batterylevel The battery charge level of device. Returns the percentage value of battery level.
com.nokia.mid.countrycode Current network country code. Returns the two-letter country code defined in ISO-3361.
com.nokia.mid.networkavailability Network availability. The property return value can contain "available" or "unavailable". available or unavailable
com.nokia.mid.networkid Network identification parameters, such as network ID (NID in CDMA and MNC in GSM) and network short name. Returns two values:

network ID network short name

com.nokia.mid.networksignal Current (GSM/CDMA) network signal strength. Returns two values:

the number of bars the phone should display the signal strength in dBm

com.nokia.mid.imei The IMEI (International Mobile Equipment Identity) of the device. Returns a 14 digit decimal number that uniquely identifies the device.
com.nokia.mid.imsi The IMSI (International Mobile Subscriber Identity) stored in the SIM card. Note that the access to this system property is limited with com.nokia.mid.mobinfo.IMSI permission. By default this permission is available only in manufacturer and operator domain. Returns the subscriber number associated with the device. The IMSI number is usually 14 decimal digits long, but it may be shorter.

The com.nokia.mid.timeformat and com.nokia.mid.dateformat system properties indicate the user preferences of date and time formats. For example, in many devices there are settings available for user to indicate the date and time formatting settings: ordering of date, month and year components of date strings, separators used between components of date and time strings, whether 12 or 24 hour clock is used, and so on. The values of above system properties indicate the currently active user preferences for these settings. MIDlets can use these values to format date and time strings they, for example, need to display in user interfaces.

No comments: