Google Maps基站定位

  如果你在你的手机装过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)"http://www.google.com/glm/mmap“.

首先读取你自己手机的CellID和LAC。 通过Http连接发送Post请求到 http://www.google.com/glm/mmap。 传入CellID和LAC参数,从API返回基站的经纬度( Latitude/Longitude)。

另外有个可以参考的例子(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;

ExpandedBlockStart.gifContractedBlock.gif
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;

ExpandedSubBlockStart.gifContractedSubBlock.gif    
public GetIMEIAndCellId() {
         display 
= Display.getDisplay(this);

     }


ExpandedSubBlockStart.gifContractedSubBlock.gif    
protected void destroyApp(boolean arg0) {

     }


ExpandedSubBlockStart.gifContractedSubBlock.gif    
protected void pauseApp() {

     }


ExpandedSubBlockStart.gifContractedSubBlock.gif    
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");
ExpandedSubBlockStart.gifContractedSubBlock.gif        
if (imei == null || "".equals(imei)) {
             imei 
= System.getProperty("com.nokia.IMEI");
         }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
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

ExpandedSubBlockStart.gifContractedSubBlock.gif        
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);
     }


ExpandedSubBlockStart.gifContractedSubBlock.gif    
public void commandAction(Command cmd, Displayable item) {
ExpandedSubBlockStart.gifContractedSubBlock.gif        
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
  

 

 

 

 

 

 

转载于:https://www.cnblogs.com/psunny/archive/2009/10/22/1587779.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值