10

i'm trying to get info about the neighboring cells my phone can "see" atm. so far so good. i do this like this:

telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
//...
ArrayList<NeighboringCellInfo> neighboringCellList = (ArrayList<NeighboringCellInfo>) telManager.getNeighboringCellInfo();

unfortunately, this list turns out to be empty all the time. even in different places. i live in berlin, so i don't think it's because there is actually just the one cell available!

update: my permissions look like this:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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_COARSE_UPDATES" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
xenonite
  • 1,671
  • 4
  • 28
  • 43
  • 1
    Have you found a solution to this problem yet? I am on Galaxy Nexus. I have tried all the suggestions below, but I still do not receive anything in the neighboring cells. – ishan Aug 22 '12 at 10:41
  • well it seems to be a problem with all Samsung devices. The same code returns the correct results on other devices... – xenonite Sep 02 '14 at 10:04
  • getNeighboringCellInfo() is deprecated and you should don't use of that . – ofskyMohsen Jul 09 '17 at 04:59

2 Answers2

3

I've seen several questions on the same issue but it seems like none of them got a good and deterministic solution. The most common suggestion is to make sure you have the correct permission (which I see you do in your question) and there are some that say that this only works on 2G and not 3G.

Take a look at the following similar questions. It might point you in some new directions:

getNeighboringCellInfo() returning null list

Null Issue with NeighboringCellInfo, CID and LAC

Get neighboring cell in Android returns null

Community
  • 1
  • 1
Muzikant
  • 8,070
  • 5
  • 54
  • 88
1

getNeighboringCellInfo() is deprecated in android . You should use getAllCellInfo() and save output of that in a List and using a loop on each element of List decide which is neighbor using element.isRegistered() . NeighboringCells have isRegistered() == false .

ofskyMohsen
  • 1,121
  • 1
  • 12
  • 26