Search code examples
androidcell

Neighbor cells have -1 for CID and LAC


In Android, I try to get the neighbor cells information. I use the following piece of code

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
List<NeighboringCellInfo> neighborCells = telephonyManager.getNeighboringCellInfo();
if (neighborCells == null) {
    Log.d("cells", "Neighbor cells is null");
} else {
    for (NeighboringCellInfo cell : neighborCells) {
        Log.d("cells", cell.getCid()+"-"+cell.getLac()+" "+(-113+cell.getRssi()*2)+"dB");
    }
}

Using logcat, I get the following output

D/cells   ( 7668): Neighbor cell: -1--1 -81dB
D/cells   ( 7668): Neighbor cell: -1--1 -113dB
D/cells   ( 7668): Neighbor cell: -1--1 -113dB

Do you know why ? Is it related with the hardware ? With another phone, I get always "Neighbor cells is null"

Thank you


Solution

  • Ok I found the solution, I needed to enable the option "use only 2G networks". What would be nice is the possibility to enable that option from my application. It seems it is not possible but strange because this application does it...

    Does somebody knows why I have more information with 2G cells than 3G ?