通过j2me获取手机imei号码和cellid(基站号)

 

本篇是本人收集到的怎么获取手机的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 lanfanss@126.com
 * 
@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:不能够获取
sonyericsson:
     c702,k818c:能够获取imei及cellid

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值