程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> J2ME >> 探討:通過j2me獲取手機imei號碼和cellid

探討:通過j2me獲取手機imei號碼和cellid

編輯:J2ME
篇是本人收集到的怎麼獲取手機的Imei和cellid的總結,由於這兩個屬性是每個廠商自己實現,故而沒有統一的方法。本人收集的也不全,測試亦是不全面。放置一篇文章在這裡,希望有興趣的人多多補充。

  資料來源如下:

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:不能夠獲取

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved