資料來源如下:
http://web.mit.edu/21w.780/www/spring2007/guide/
http://wiki.forum.nokia.com/index.PHP/CS000947_-_Getting_Cell_ID_in_Java_ME
http://forums.sun.com/thread.JSPa?threadID=5278668
https://developer.sonyeriCSSon.com/message/110949
測試代碼如下,當中使用了polish做適配:
package study;
import Javax.microedition.lcdui.Command;
import Javax.microedition.lcdui.CommandListener;
import Javax.microedition.lcdui.Display;
import Javax.microedition.lcdui.Displayable;
import Javax.microedition.midlet.MIDlet;
import Javax.microedition.midlet.MIDletStateChangeException;
import de.enough.polish.ui.Form;
/**
*
* @author: zhanghongzhi [email protected]
* @version: 0.1
* @time: 2008-8-10 下午01:56:17
*
*/
public class GetIMEIAndCellId extends MIDlet implements CommandListener {
private Command exitCommand = new Command("exit", Command.EXIT, 1);
Form form = new Form("imei and cellid");
Display display = null;
public GetIMEIAndCellId() {
display = Display.getDisplay(this);
}
protected void destroyApp(boolean arg0) {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
//獲取系統信息
String info = System.getProperty("microedition.platform");
//獲取到imei號碼
String imei = "";
//cellid
String cellid = "";
//lac
String lac = "";
//#if polish.vendor==Sony-EriCSSon
imei = System.getProperty("com.sonyeriCSSon.imei");
//參考 http://forums.sun.com/thread.JSPa?threadID=5278668
//https://developer.sonyeriCSSon.com/message/110949
cellid = System.getProperty("com.sonyeriCSSon.Net.cellid");
//獲取索愛機子的
lac = System.getProperty("com.sonyeriCSSon.Net.lac");
//#else if polish.vendor==Nokia
imei = System.getProperty("phone.imei");
if (imei == null || "".equals(imei)) {
imei = System.getProperty("com.nokia.IMEI");
}
if (imei == null || "".equals(imei)) {
imei = System.getProperty("com.nokia.mid.imei");
}
//獲取到cellid
//參考http://wiki.forum.nokia.com/index.PHP/CS000947_-_Getting_Cell_ID_in_Java_ME
//#if polish.group==SerIEs60
cellid = System.getProperty("com.nokia.mid.cellid");
//#else if polish.group==SerIEs40
cellid = System.getProperty("Cell-ID");
//#endif
//#else if polish.vendor==SIEmens
imei = System.getProperty("com.sIEmens.imei");
//#else if polish.vendor==Motorola
imei = System.getProperty("com.motorola.IMEI");
//cellid 參考 http://web.mit.edu/21w.780/www/spring2007/guide/
cellid = System.getProperty("CellID");
//#else if polish.vendor==Samsung
imei = System.getProperty("com.samsung.imei");
//#endif
if (imei == null || "".equals(imei)) {
imei = System.getProperty("IMEI");
}
//展示出來
form.append("platforminfo:" + info);
form.append("imei:" + imei);
form.append("cellid:" + cellid);
form.setCommandListener(this);
form.addCommand(exitCommand);
display.setCurrent(form);
}
public void commandAction(Command cmd, Displayable item) {
if (cmd == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
目前我手機的測試結果如下,希望大家能夠補充測試結果或者指出文中纰漏之處:
夏普-sh9010c:不能夠獲取