I have been trying to get celllid,lac,mcc and mnc. While mcc and mnc can be found,cell-id and lac still are null.Here's the code (and it is known to work according to number of threads going on but I still can't get it to work)
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author lalchetian
*/
public class LocInfo extends MIDlet {
private Form form;
private Display display;
public void startApp() {
form = new Form("Location...");
String cellid = getCellId();
String getLAC = getLAC();
String getMCC = getMCC();
String getMNC = getMNC();
form.append(cellid);
form.append("<-this is cell-id");
form.append(getLAC);
form.append("<-this is LAC");
form.append(getMCC);
form.append("<-this is MCC");
form.append(getMNC);
form.append("<-this is MNC");
display = Display.getDisplay(this);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
/**
* get the cell id in the phone
*
* @return
*/
public static String getCellId(){
String out = "";
try{
out = System.getProperty("com.nokia.mid.cellid");
}catch(Exception e){
System.out.println(e);
out=e.toString();
return out;
}
return out==null?""ut;
}
/**
* get the lac sring from phone
*/
public static String getLAC(){
String out = "";
try{
out = System.getProperty("com.nokia.mid.lac");
}catch(Exception e){
out=e.toString();
return out;
}
return out==null?""ut;
}
/**
* Example IMSI (O2 UK): 234103530089555
String mcc = imsi.substring(0,3); // 234 (UK)
String mnc = imsi.substring(3,5); // 10 (O2)
* @return
*/
public static String getIMSI(){
String out = "";
try{
out = System.getProperty("IMSI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("phone.imsi") ;
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.nokia.mid.imsi");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.sonyericsson.imsi");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("IMSI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.samsung.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.siemens.imei");
if(out== null ||out.equals("null")|| out.equals(""))
//#= out = GPRSInfo.getCellInfo().getBSIC();
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("imsi");
}catch(Exception e){
return out==null?""ut;
}
return out==null?""ut;
}
/**
*
* For moto, Example IMSI (O2 UK): 234103530089555
String mcc = imsi.substring(0,3); // 234 (UK)
* @return
*/
public static String getMCC(){
String out = "";
try{
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("phone.mcc") ;
if(out== null ||out.equals("null")|| out.equals(""))
//out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.sonyericsson.net.mcc");
if(out== null ||out.equals("null")|| out.equals("")){
out = getIMSI().equals("")?"": getIMSI().substring(0,3);
}
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.samsung.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.siemens.imei");
if(out== null ||out.equals("null")|| out.equals(""))//getMNC()
//#= out = GPRSInfo.getCellInfo().getMCC();
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("mcc");
}catch(Exception e){
return out==null?""ut;
}
return out==null?""ut;
}
/**
*
* For moto, Example IMSI (O2 UK): 234103530089555
String mnc = imsi.substring(3,5); // 10 (O2)
* @return
*/
public static String getMNC(){
String out = "";
try{
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("phone.mnc") ;
if(out== null ||out.equals("null")|| out.equals(""))
out = getIMSI().equals("")?"": getIMSI().substring(3,5);
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.sonyericsson.net.mnc");
if(out== null ||out.equals("null")|| out.equals("")){
out = getIMSI().equals("")?"": getIMSI().substring(3,5);
}
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.samsung.imei");
/* if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.siemens.imei");*/
if(out== null ||out.equals("null")|| out.equals(""))//getMNC()
//#= out = GPRSInfo.getCellInfo().getMNC();
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("mnc");
}catch(Exception e){
return out==null?""ut;
}
return out==null?""ut;
}
/**
* not used now
* get the IMEI (International Mobile Equipment Identity (IMEI)) in the phone
*
* @return
*/
public static String getIMEI(){
String out = "";
try{
out = System.getProperty("com.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("phone.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.nokia.IMEI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.nokia.mid.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.nokia.mid.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.sonyericsson.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("IMEI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.motorola.IMEI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.samsung.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.siemens.imei");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("imei");
}catch(Exception e){
return out==null?""ut;
}
return out==null?""ut;
}
}
I have taken code from here - >http://www.easywms.com/easywms/?q=en/node/3589 (Iwant it to run on nokia e50 as of now and hence used com.nokia.mid.cellid (in fact i have tried all other options mentioned on this link as well)) Cellid and lac both returns null while mcc and mnc are returned correctly.

ut;
Reply With Quote


