0

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.*;


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) {
}

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?"":out;
}
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?"":out;
}


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?"":out;
}

return out==null?"":out;
}


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?"":out;
}

return out==null?"":out;
}


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(""))//getMNC()
//#= out = GPRSInfo.getCellInfo().getMNC();

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("mnc");


}catch(Exception e){
return out==null?"":out;
}

return out==null?"":out;
}

}

I have taken code from here (I want 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.

bharath
  • 14,283
  • 16
  • 57
  • 95
lalchetian
  • 103
  • 1
  • 9

3 Answers3

1

I confirm Cell ID can't be received from E50. But I have written kind of multiplatform solution and I am going to check this on wide range of devices (>1000 devices in our production enviroment). I'd got the prototype from same link but to be honest - person who wrote it doesn't give a shit to details.

I very doubt my code will work on at least half of the devices but we will see it soon anyway.

    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());
    }
}
  • so have you been able to get the code to work? I am interested because I am thinking of implementing it within LWUIT. thanks for your response, in advance. – Daydah Apr 12 '12 at 08:57
0

Which you site mentioned in that have you read this line

But get Cellid is still limited by mobile phone platform, Sign-certificate and Operator:

Nokia s40 3rd Fp1 edition, requers operator or manufactureer signing S60 3rd edition, FP2(released 2008 and newer, does not work on e.g. N95),no singing required.

Mr. Sajid Shaikh
  • 7,051
  • 4
  • 21
  • 35
  • I didn't get what is that supposed to mean but nokia developer library -> http://library.developer.nokia.com/index.jsp?topic=/Java_Developers_Library/GUID-A1F90B63-5F14-4829-BCA1-A23B925CF670.html mentions "Note: From Series 40 5th Edition FP1 to Series 40 6th Edition FP1, this property is available only in the manufacturer and operator domains. From Java Runtime 1.0.0 for Series 40 onwards, this property is available in all domains" . So that If i am not wrong means that it is available without signing in E50 which is a symbian Series 60 phone... – lalchetian Jun 23 '11 at 12:18
  • and I just tried it on E63 which is a S60 3rd edition fp1 phone and surprisingly,It gives Cell-id but no mcc,mnc and lac.E50 on other hand returned mcc and mnc but no Cellid and LAC. – lalchetian Jun 23 '11 at 13:04
0

I just got a Nokia device S60 whit Symbian release 5 here at work, and I'm trying to get the cell phone location based on the cell id, not the gps. So, for that, I use http://www.opencellid.org/, this page retrieves me the position, but it is not exactly such as the gps'. But, for doing that I need the mnc, the mcc, the cellid, and the lac, and for my surprise, this device is not giving me the lac, mnc and mcc, such lalchetian said. We have a serious problem, here. It might be that these properties are only available in some devices only.

Nadia
  • 1
  • 1