Java me 无法在诺基亚S60上检索手机id和LAC(在E50中试用)
我一直在努力争取celllid、lac、mcc和mnc。虽然可以找到mcc和mnc,但cell id和lac仍然是空的。下面是代码(根据正在进行的线程数知道它可以工作,但我仍然无法让它工作)Java me 无法在诺基亚S60上检索手机id和LAC(在E50中试用),java-me,nokia,s60,cellid,Java Me,Nokia,S60,Cellid,我一直在努力争取celllid、lac、mcc和mnc。虽然可以找到mcc和mnc,但cell id和lac仍然是空的。下面是代码(根据正在进行的线程数知道它可以工作,但我仍然无法让它工作) import javax.microedition.midlet.*; 导入javax.microedition.lcdui.*; 公共类LocInfo扩展MIDlet{ 私人形式; 私人显示器; 公开作废startApp(){ 表格=新表格(“位置…”); 字符串cellid=getCellId(); 字
import javax.microedition.midlet.*;
导入javax.microedition.lcdui.*;
公共类LocInfo扩展MIDlet{
私人形式;
私人显示器;
公开作废startApp(){
表格=新表格(“位置…”);
字符串cellid=getCellId();
字符串getLAC=getLAC();
字符串getMCC=getMCC();
字符串getMNC=getMNC();
附加形式(cellid);
append(“你在网站上提到的,你读过这一行了吗
但get Cellid仍受到手机平台、签名证书和运营商的限制:
诺基亚
s40第三版Fp1,要求操作员或制造商签字
S60第三版,FP2(2008年及更新版本发布,不适用于N95等),无需唱歌
我刚买了一台诺基亚S60,带Symbian release 5,我正试图根据手机id,而不是gps来获取手机位置。因此,我使用此页面检索位置,但它与gps不完全相同。但是,要做到这一点,我需要mnc、mcc、手机id和lac,让我惊讶的是,这个开发工具lalchetian说,ice没有给我lac、mnc和mcc。我们这里有一个严重的问题。可能这些属性只在某些设备上可用。我确认E50无法接收到Cell ID。但我已经编写了一种多平台解决方案,我将在广泛的设备上对此进行检查(>1000台设备在我们的生产环境中)。我从同一个链接得到了原型,但老实说——写这个的人根本不在乎细节
我非常怀疑我的代码是否能在至少一半的设备上运行,但我们很快就会看到它
package Device;
import dct.CellData;
public class DeviceInfo {
static private DeviceInfo instance;
private int platformID;
static public DeviceInfo instance(int platformID) {
if (instance == null || instance.platformID != platformID)
instance = new DeviceInfo(platformID);
return instance;
}
private DeviceInfo(int platformID) {
this.platformID = platformID;
}
private String readProperty(String propertyName) {
String val = System.getProperty(propertyName);
return (val == null || val.length() == 0 || val.equals("null")) ? "" : val;
}
/**
* get the cell id in the phone
*
* @return
*/
public String getCellId() {
try {
String out = readProperty("Device-ID");
if (out.length() > 0) return out;
out = readProperty("CellID");
if (out.length() > 0) return out;
out = readProperty("phone.cid");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.cellid";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.net.cellid";
break;
case Platforms.PLATFORM_SAMSUNG:
propertyName = "com.samsung.cellid";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.net.cellid";
break;
case Platforms.PLATFORM_MOTOROLA:
propertyName = "phone.cid";
break;
case Platforms.PLATFORM_SIEMENS:
propertyName = "com.siemens.cellid";
break;
case Platforms.PLATFORM_NOT_DEFINED:
default:
propertyName = "cid";
break;
}
return readProperty(propertyName);
}
catch (Exception ex) {
return "";
}
}
/**
* get the lac sring from phone
*/
public String getLAC() {
try {
String out = readProperty("phone.lac");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.lac";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.net.lac";
break;
case Platforms.PLATFORM_MOTOROLA:
propertyName = "LocAreaCode";
break;
case Platforms.PLATFORM_SIEMENS: // didn't try to find
case Platforms.PLATFORM_SAMSUNG: // can't find
case Platforms.PLATFORM_LG: // not supported (http://sourceforge.net/tracker/index.php?func=detail&aid=3310226&group_id=192084&atid=939977)
case Platforms.PLATFORM_NOT_DEFINED:
default:
return "";
}
return readProperty(propertyName);
}
catch (Exception ex) {
return "";
}
}
/**
* Example IMSI (O2 UK): 234103530089555
* <p/>
* String mcc = imsi.substring(0,3); // 234 (UK)
* <p/>
* String mnc = imsi.substring(3,5); // 10 (O2)
*
* @return
*/
public String getIMSI() {
try {
String out = readProperty("IMSI");
if (out.length() > 0) return out;
out = readProperty("phone.imsi");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
out = readProperty("com.nokia.mid.mobinfo.IMSI");
if (out.length() > 0) return out;
propertyName = "com.nokia.mid.imsi";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.imsi";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.imsi";
break;
case Platforms.PLATFORM_SAMSUNG:
case Platforms.PLATFORM_MOTOROLA:
case Platforms.PLATFORM_SIEMENS:
case Platforms.PLATFORM_NOT_DEFINED:
default:
return "";
}
return readProperty(propertyName);
}
catch (Exception ex) {
return "";
}
}
/**
* For moto, Example IMSI (O2 UK): 234103530089555
* <p/>
* String mcc = imsi.substring(0,3); // 234 (UK)
*
* @return
*/
public String getMCC() {
try {
String out = readProperty("phone.mcc");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.countrycode";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.net.mcc";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.cmcc";
break;
}
if (propertyName != null)
out = readProperty(propertyName);
if (out.length() == 0) {
out = getIMSI();
if (out.length() > 0)
out = out.substring(0, 3);
}
return out;
} catch (Exception e) {
return "";
}
}
/**
* For moto, Example IMSI (O2 UK): 234103530089555
* <p/>
* String mnc = imsi.substring(3,5); // 10 (O2)
*
* @return
*/
public String getMNC() {
try {
String out = readProperty("phone.mnc");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.networkid";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.net.mnc";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.cmnc";
break;
}
if (propertyName != null)
out = readProperty(propertyName);
if (out.length() == 0) {
out = getIMSI();
if (out.length() > 0)
out = out.substring(3, 5);
}
return out;
} catch (Exception e) {
return "";
}
}
/**
* not used now
* <p/>
* get the IMEI (International Mobile Equipment Identity (IMEI)) in the phone
*
* @return
*/
public String getIMEI() {
try {
String out = readProperty("com.imei");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.imei";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.imei";
break;
case Platforms.PLATFORM_SAMSUNG:
propertyName = "com.samsung.imei";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.imei";
break;
case Platforms.PLATFORM_MOTOROLA:
propertyName = "com.motorola.imei";
break;
case Platforms.PLATFORM_SIEMENS:
propertyName = "com.simens.imei";
break;
case Platforms.PLATFORM_NOT_DEFINED:
default:
propertyName = "";
break;
}
return readProperty(propertyName);
} catch (Exception e) {
return "";
}
}
public void fillCellData(CellData data) {
data.setCellid(getCellId());
data.setLAC(getLAC());
data.setMCC(getMCC());
data.setMNC(getMNC());
}
}
封装设备;
导入dct.CellData;
公共类设备信息{
静态私有设备信息实例;
私有int平台;
静态公共设备信息实例(int platformID){
if(instance==null | | instance.platformID!=platformID)
实例=新设备信息(platformID);
返回实例;
}
专用设备信息(int platformID){
这个。平台状=平台状;
}
私有字符串读取属性(字符串属性名称){
字符串val=System.getProperty(propertyName);
返回值(val==null | | val.length()==0 | | val.equals(“null”)?“”:val;
}
/**
*在手机中获取手机id
*
*@返回
*/
公共字符串getCellId(){
试一试{
String out=readProperty(“设备ID”);
如果(out.length()>0)返回out;
out=readProperty(“CellID”);
如果(out.length()>0)返回out;
out=readProperty(“phone.cid”);
如果(out.length()>0)返回out;
字符串propertyName=null;
开关(平台式){
case Platforms.PLATFORM_诺基亚:
propertyName=“com.nokia.mid.cellid”;
打破
case Platforms.PLATFORM_索尼_爱立信:
propertyName=“com.sonyericsson.net.cellid”;
打破
case PLATFORM.PLATFORM_三星:
propertyName=“com.samsung.cellid”;
打破
案例平台.Platforms_LG:
propertyName=“com.lge.net.cellid”;
打破
case Platforms.PLATFORM_摩托罗拉:
propertyName=“phone.cid”;
打破
案例平台。西门子平台:
propertyName=“com.siemens.cellid”;
打破
案例平台。未定义平台:
违约:
propertyName=“cid”;
打破
}
返回readProperty(propertyName);
}
捕获(例外情况除外){
返回“”;
}
}
/**
*从电话中获取lac sring
*/
公共字符串getLAC(){
试一试{
String out=readProperty(“phone.lac”);
如果(out.length()>0)返回out;
字符串propertyName=null;
开关(平台式){
case Platforms.PLATFORM_诺基亚:
propertyName=“com.nokia.mid.lac”;
打破
case Platforms.PLATFORM_索尼_爱立信:
propertyName=“com.sonyericsson.net.lac”;
打破
case Platforms.PLATFORM_摩托罗拉:
propertyName=“LocAreaCode”;
打破
case Platforms.PLATFORM_SIEMENS://未尝试查找
case Platforms.PLATFORM_SAMSUNG://找不到
case Platforms.PLATFORM_LG://不支持(http://sourceforge.net/tracker/index.php?func=detail&aid=3310226&group_id=192084&atid=939977)
案例平台。未定义平台:
违约:
返回“”;
}
返回readProperty(propertyName);
}
捕获(例外情况除外){
返回“”;
}
}
/**
*示例IMSI(O2英国):234103530809555
*
*字符串mcc=imsi.substring(0,3);//234(英国)
*
*字符串mnc=imsi.substring(3,5);//10(O2)
*
*@返回
*/
公共字符串getIMSI(){
试一试{
字符串输出=读取属性(“IMSI”);
如果(out.length()>0)返回out;
out=readProperty(“phone.imsi”);
如果(out.length()>0)返回out;
字符串propertyName=null;
开关(平台式){
case Platforms.PLATFORM_诺基亚:
out=readProperty(“com.nokia.mid.mobinfo.IMSI”);
如果(out.len)
package Device;
import dct.CellData;
public class DeviceInfo {
static private DeviceInfo instance;
private int platformID;
static public DeviceInfo instance(int platformID) {
if (instance == null || instance.platformID != platformID)
instance = new DeviceInfo(platformID);
return instance;
}
private DeviceInfo(int platformID) {
this.platformID = platformID;
}
private String readProperty(String propertyName) {
String val = System.getProperty(propertyName);
return (val == null || val.length() == 0 || val.equals("null")) ? "" : val;
}
/**
* get the cell id in the phone
*
* @return
*/
public String getCellId() {
try {
String out = readProperty("Device-ID");
if (out.length() > 0) return out;
out = readProperty("CellID");
if (out.length() > 0) return out;
out = readProperty("phone.cid");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.cellid";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.net.cellid";
break;
case Platforms.PLATFORM_SAMSUNG:
propertyName = "com.samsung.cellid";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.net.cellid";
break;
case Platforms.PLATFORM_MOTOROLA:
propertyName = "phone.cid";
break;
case Platforms.PLATFORM_SIEMENS:
propertyName = "com.siemens.cellid";
break;
case Platforms.PLATFORM_NOT_DEFINED:
default:
propertyName = "cid";
break;
}
return readProperty(propertyName);
}
catch (Exception ex) {
return "";
}
}
/**
* get the lac sring from phone
*/
public String getLAC() {
try {
String out = readProperty("phone.lac");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.lac";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.net.lac";
break;
case Platforms.PLATFORM_MOTOROLA:
propertyName = "LocAreaCode";
break;
case Platforms.PLATFORM_SIEMENS: // didn't try to find
case Platforms.PLATFORM_SAMSUNG: // can't find
case Platforms.PLATFORM_LG: // not supported (http://sourceforge.net/tracker/index.php?func=detail&aid=3310226&group_id=192084&atid=939977)
case Platforms.PLATFORM_NOT_DEFINED:
default:
return "";
}
return readProperty(propertyName);
}
catch (Exception ex) {
return "";
}
}
/**
* Example IMSI (O2 UK): 234103530089555
* <p/>
* String mcc = imsi.substring(0,3); // 234 (UK)
* <p/>
* String mnc = imsi.substring(3,5); // 10 (O2)
*
* @return
*/
public String getIMSI() {
try {
String out = readProperty("IMSI");
if (out.length() > 0) return out;
out = readProperty("phone.imsi");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
out = readProperty("com.nokia.mid.mobinfo.IMSI");
if (out.length() > 0) return out;
propertyName = "com.nokia.mid.imsi";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.imsi";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.imsi";
break;
case Platforms.PLATFORM_SAMSUNG:
case Platforms.PLATFORM_MOTOROLA:
case Platforms.PLATFORM_SIEMENS:
case Platforms.PLATFORM_NOT_DEFINED:
default:
return "";
}
return readProperty(propertyName);
}
catch (Exception ex) {
return "";
}
}
/**
* For moto, Example IMSI (O2 UK): 234103530089555
* <p/>
* String mcc = imsi.substring(0,3); // 234 (UK)
*
* @return
*/
public String getMCC() {
try {
String out = readProperty("phone.mcc");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.countrycode";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.net.mcc";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.cmcc";
break;
}
if (propertyName != null)
out = readProperty(propertyName);
if (out.length() == 0) {
out = getIMSI();
if (out.length() > 0)
out = out.substring(0, 3);
}
return out;
} catch (Exception e) {
return "";
}
}
/**
* For moto, Example IMSI (O2 UK): 234103530089555
* <p/>
* String mnc = imsi.substring(3,5); // 10 (O2)
*
* @return
*/
public String getMNC() {
try {
String out = readProperty("phone.mnc");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.networkid";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.net.mnc";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.cmnc";
break;
}
if (propertyName != null)
out = readProperty(propertyName);
if (out.length() == 0) {
out = getIMSI();
if (out.length() > 0)
out = out.substring(3, 5);
}
return out;
} catch (Exception e) {
return "";
}
}
/**
* not used now
* <p/>
* get the IMEI (International Mobile Equipment Identity (IMEI)) in the phone
*
* @return
*/
public String getIMEI() {
try {
String out = readProperty("com.imei");
if (out.length() > 0) return out;
String propertyName = null;
switch (platformID) {
case Platforms.PLATFORM_NOKIA:
propertyName = "com.nokia.mid.imei";
break;
case Platforms.PLATFORM_SONY_ERICSSON:
propertyName = "com.sonyericsson.imei";
break;
case Platforms.PLATFORM_SAMSUNG:
propertyName = "com.samsung.imei";
break;
case Platforms.PLATFORM_LG:
propertyName = "com.lge.imei";
break;
case Platforms.PLATFORM_MOTOROLA:
propertyName = "com.motorola.imei";
break;
case Platforms.PLATFORM_SIEMENS:
propertyName = "com.simens.imei";
break;
case Platforms.PLATFORM_NOT_DEFINED:
default:
propertyName = "";
break;
}
return readProperty(propertyName);
} catch (Exception e) {
return "";
}
}
public void fillCellData(CellData data) {
data.setCellid(getCellId());
data.setLAC(getLAC());
data.setMCC(getMCC());
data.setMNC(getMNC());
}
}