1

I'm trying to get the neighbouring cell info in Android but the function getNeighboringCellInfo() always return null.

I used the following code :

protected void getCellInfo() {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    List<NeighboringCellInfo> neighborCells = telephonyManager.getNeighboringCellInfo();
    if (neighborCells == null) {
        OutUtils.debug("no neighbor cells");
    } else {
        ...
    }
}

The context variable is from a Service class.

My AndroidManifest.xml permission

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

I tried with and without enabling the "Use 2G networks" option in Android.

Any idea ? Thanks

Martin Trigaux
  • 5,311
  • 9
  • 45
  • 58

3 Answers3

4

If you can run logcat, try running logcat -b radio. If you are lucky, the RIL code will be spitting out debug messages, showing the actual request to the modem for the neighboring cell info. It could well be that the modem is just returning an empty list. If this is the case, it has nothing to do with permissions, and there is not much you can to fix it.

Cesar Maiorino
  • 563
  • 5
  • 16
  • 1
    I confirm. On a Samsung Galaxy S, the radio returns: REQUEST_GET_NEIGHBORING_CELL_IDS error: com.android.internal.telephony.CommandException: REQUEST_NOT_SUPPORTED. – monxalo May 16 '13 at 16:01
1

The cellid implementation varies from mobile device to mobile device since these features are considered to be optional. for example:

Samsung (all devices): getNeigbouringCells () is not supported at all and always returns an empty list.

according to this: http://wiki.opencellid.org/wiki/Android_library

and this: https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=24306

Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
0

I think, maybe you haven't set all necessary permissions in Manifest. look here Null Issue with NeighboringCellInfo, CID and LAC

If you think you have them, put the manifest in the question, too, please.

Community
  • 1
  • 1
Gangnus
  • 24,044
  • 16
  • 90
  • 149