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"); |
Code:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class MobileProperties extends MIDlet implements CommandListener {
Form f = null;
Display dis = null;
Command ok = null;
Command exit = null;
String s1= null;
public MobileProperties () {
dis=Display.getDisplay(this);
f = new Form(" Mobile Details ");
ok =new Command(" Ok",Command.OK,1);
exit =new Command(" Exit",Command.EXIT,2);
f.addCommand(ok);
f.addCommand(exit);
f.setCommandListener(this);
}
public void startApp(){
try {
if ((s1 = System.getProperty("phone.imei")) == null || s1.equals("")) {
s1 = System.getProperty("com.nokia.mid.imei");
}
if (s1 == null || s1.equals("")) {
s1 = System.getProperty("com.sonyericsson.imei");
}
} catch(Exception e) {
f.append("Exception :"+e);
}
dis.setCurrent(f);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == ok) {
destroyApp(true);
notifyDestroyed();
} else if (c==exit) {
destroyApp(true);
notifyDestroyed();
}
}
}
No comments:
Post a Comment