posts - 41,  comments - 90,  trackbacks - 0
          Google Maps基站定位
          (轉載至http://www.cnblogs.com/psunny/archive/2009/10/22/1587779.html)

          如果你在你的手機裝過Google Mobile Maps,你就可以發現只要你的手機能連接GPRS,即使沒有GPS功能,也能定位到你手機所在的位置, 只是精度不夠準確。在探討這個原理之前,我們需要了解一些移動知識,了解什么是MNC/LAC/Cell ID。
          • Mobile Network Code(MNC)
            移動網號碼,中國聯通CDMA系統的MNC為03,中國移動的為00。
          • Mobile Country Code(MCC)
            移動用戶所屬國家代號:460
          • Location Area Code(LAC)
            地區區域碼,用來劃分區域,一般一個小地方就一個LAC,大地方就
          • Cell Tower ID(Cell ID)
            CellID代表一個移動基站,如果你有基站數據,查CellID你就可以知道這個基站在哪里,移動公司或者警察通過這個知道你是在哪個基站范圍打的移動電話。

          這些信息有什么用呢? 通過這些信息可以知道你的手機是從哪個國家,區域和哪個基站接入移動網絡的。所以有些防盜手機丟失后,會發一些類 似"MCC:460;MNC:01;LAC:7198:CELLID:24989"內容的短信到你指定號碼就是這個用途,通過這些信息可以從移動查到你的 被盜手機在哪里出現過。不過知道了也沒用,中國人口這么密集,就是在你身邊你也不知道誰是小偷:) 

            這些信息從哪里來呢,一般的手機系統都提供相應的API來獲取這些信息(Tower Info),比如Window SmartPhone 或Mobile就是通過RIL.dll里的API來取得,每個手機操作系統不一樣,相關的信息可以查相關資料。

          得到了這些信息,如果沒有基站信息表,得到了這些信息也不知道在哪,因為只有移動運營商有相關的信息,除非你是運營商或者警察才能得到這些信息。是 不是我們就查不到相應的數據呢,當然不是,強大的Google就有,這里就要提到Google Mobile Maps API,里面囊括了比較全的基站信息,中國的也有,就是偏遠地區的有沒有就不知道了。Google Mobile Maps本身就是使用的這些信息,感興趣可以試一試,沒有GPS模塊也能定位到你手機位置,但精度不大,取決于基站的位置離你多遠。

            同樣我們自己也可以開發相應的手機應用來定位,只要調用Google現成的API(Secret API)“.

        1. 首先讀取你自己手機的CellID和LAC。
        2. 通過Http連接發送Post請求到http://www.google.com/glm/mmap
        3. 傳入CellID和LAC參數,從API返回基站的經緯度(Latitude/Longitude)。
        4. 另外有個可以參考的例子(windows mobile)http://www.codeproject.com/KB/mobile/DeepCast.aspx

             下面是通過j2me獲取手機imei號碼和cellid(基站號)的例子

          package jizhan;
          import javax.microedition.lcdui.Command;
          import javax.microedition.lcdui.CommandListener;
          import javax.microedition.lcdui.Display;
          import javax.microedition.lcdui.Displayable;
          import javax.microedition.lcdui.Form;
          import javax.microedition.midlet.MIDlet;
          import javax.microedition.midlet.MIDletStateChangeException;

          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();
                   }

               }


          }

            需要注意的是,必須是受信任的Midlet才可以取到這些數據。也就是說Midlet必須經過簽名上述代碼才可以工作,否則獲取到的是NULL。。
          下面是從別的地方看來的,沒做過測試,供參考。
          a) Nokia = System.getProperty("com.nokia.mid.imei");
          System.getProperty("com.nokia.IMEI");
          System.getProperty("phone.imei");
          b) Samsung
          System.getProperty("com.samsung.imei");
          c) Sony-Ericsson
          System.getProperty("com.sonyericsson.imei");

          IMSI: IMSI全稱是International Mobile Subscriber Identification Number,移動用戶身份碼。當手機開機后,在接入網絡的過程中有一個注冊登記的過程,系統通過控制信道將經加密算法后的參數組傳送給客戶,手機中的 SIM卡收到參數后,與SIM卡存儲的客戶鑒權參數經同樣算法后對比,結果相同就允許接入,否則為非法客戶,網絡拒絕為此客戶服務。IMSI唯一的標志了 一個SIM卡。
          IMEI: IMEI即International Mobile Equipment Identity(國際移動設備身份)的簡稱,也被稱為串號,它唯一標志了一臺移動設備,比如手機。 IMEI碼一般由15位數字組成,絕大多數的GSM手機只要按下“*#06#”,IMEI碼就會顯示出來。其格式如下: TAC即Type Approval Code,為設備型號核準號碼。FAC即Final Assembly Code,為最后裝配號碼。 SNR即Serial Number,為出廠序號。 SP即Spare Number,為備用號碼。  

            有時候,我們在應用中需要獲取IMSI或者IMEI號用于將應用程序和手機或SIM卡綁在一起。獲取的方式在各不同廠商的各款手機上不盡相同,在motorola RAZR E6   上采用System.getProperty()獲取。相應程序代碼是:

                       String imei= System.getProperty("IMEI"); //for E6
                       if ( null == imei )
                           imei = System.getProperty("phone.IMEI");
                      
                       String imsi = System.getProperty("IMSI"); //for E6
                       if ( null == imsi )
                           imei = System.getProperty("phone.IMSI");
                      
                       g.drawString("IMEI: "+imei, 10, 50, Graphics.LEFT | Graphics.TOP);

                       g.drawString("IMSI: "+imsi, 10, 70, Graphics.LEFT | Graphics.TOP);

          參考地址:
          http://blog.csdn.net/phiger/archive/2009/07/22/4371922.aspx
          http://hi.baidu.com/lfcomputer/blog/item/0520e0d37a410a3c970a16c1.html
          http://wiki.forum.nokia.com/index.php/CS000947_-_Getting_Cell_ID_in_Java_ME
          posted on 2009-12-03 16:30 天狼 閱讀(2990) 評論(4)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 房产| 南乐县| 安达市| 饶平县| 玉门市| 刚察县| 彭水| 巴中市| 松江区| 葫芦岛市| 清苑县| 夹江县| 永宁县| 容城县| 吉林省| 龙岩市| 阳朔县| 雷州市| 德昌县| 精河县| 阿克陶县| 凌源市| 湖州市| 上犹县| 龙川县| 资兴市| 抚州市| 无锡市| 新营市| 始兴县| 东安县| 山阴县| 三都| 邹平县| 巨野县| 宜川县| 池州市| 昭平县| 台东县| 兴隆县| 巨野县|