Wei_zhang
Wei_zhang

Reputation: 21

Android API 17 TelephonyManager.getAllCellInfo() and TelephonyManager.getNeighboringCellInfo()

Recently I was trying to get the neighboring cell information using Android devices. And I have tried many brands of android phones, such as samsung, htc. The result is just Htc can get the neighboring cell information. The function i used was TelephonyMananger.getNeiboringCellInfo(). But just as the documentation of Android API says, when i want to get the cell id and signal strength of 3G base stations, I can only get the signal strength value , and all the neighboring cell id is -1. So i changed my method. But when I use the TelephonyManager.getAllCellInfo(), the method always return a null object. Someone has asked the question before, and the answer is that the implementation of this method always return null. Here, my question is that whether we can get the neighboring cell information of 3G base stations ? And can we just implement the getAllCellInfo() method ourselves just like the getNeighboringCellInfo()? And is there any other method for us to get the 3G neighboring cell information?

Upvotes: 2

Views: 5775

Answers (2)

user149408
user149408

Reputation: 5881

Android offers three different ways of getting cell info:

  • onCellLocationChanged: GSM/UMTS and CDMA, limited to current (serving) cell.
  • getNeighboringCellInfo: GSM/UMTS only, will get neighboring cells, but not supported on all devices
  • onCellInfoChanged: all network types supported but requires API 17, not supported on all devices

In addition, the first two will not return the MCC/MNC (country and carrier code), which you will need to obtain separately from TelephonyManager.

getNeighboringCellInfo will get you just one identifier: the LAC/CID pair for GSM, or the PSC for UMTS. (The PSC is unique in the immediate surroundings of the cell.)

onCellInfoChanged may not return all cell types. This depends on the device – some will use onCellLocationChanged for GSM/UMTS cells and report only LTE cells through onCellInfoChanged.

You're pretty much at the mercy of the device (or its ROM) here. The only thing you can rely on is that a combination of the first and third method will get you the serving cell.

If one of the above methods does not work, there is nothing an app can do. You would need to build your own ROM, possibly also RIL drivers and even baseband firmware. On any of these three layers the developers may have decided that reporting nearby cells to the upper layer isn't worth the effort.

Upvotes: 1

Dave
Dave

Reputation: 71

Several telephone don't support getNeighboringCellInfo(), like many Samsung telephones (Galaxy S3, Galaxy Nexus, etc). I don't think there are solutions for this. Because error doesn't come from Android OS. So you change another version of Android or use other functions will not work.

Upvotes: 0

Related Questions