有时候,我们在应用中需要获取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);
。
需要注意的是,必须是受信任的Midlet才可以取到这些数据。也就是说Midlet必须经过签名上述代码才可以工作,否则获取到的是NULL。有关签名(sign)的知识,我在另外的文章中加以介绍。
下面是从别的地方看来的,没做过测试,供参考。
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");
PS.
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,为备用号码。
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);
。
需要注意的是,必须是受信任的Midlet才可以取到这些数据。也就是说Midlet必须经过签名上述代码才可以工作,否则获取到的是NULL。有关签名(sign)的知识,我在另外的文章中加以介绍。
下面是从别的地方看来的,没做过测试,供参考。
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");
PS.
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,为备用号码。