GetAllCellInfo returns null in android 4.2.1

My version of Android is 4.2.1, and I'm trying to use the TelephonyManager.getAllCellInfo() method. In my manifest file, I have permissions ACCESS_COARSE_UPDATES , ACCESS_COARSE_LOCATION , ACCESS_FINE_LOCATION . However, this method returns null .

+7
source share
3 answers

From TelephonyManager.getAllCellInfo() javadoc:

This is preferable to using getCellLocation, although for older devices this may return null, in which case getCellLocation should be called.

Some sources report that this method is only implemented on CDMA / LTE devices, while other types of devices (including GSM / LTE) return null. Where implemented, it will return only LTE cells.

TelephonyManager.getCellLocation() will only return GSM / UMTS or CDMA cells. It is limited to one cell, the one with which the device is currently registered. This is your safest bet if you are sure that your code will only work on GSM / UMTS or CDMA devices, and if you are only interested in the cell with which the device is currently registered.

For information about other surrounding cells, use TelephonyManager.getNeighboringCellInfo() . However, it is limited to GSM / UMTS cells. In addition, its implementation depends on the firmware of the radio. Most Samsung devices (and many others) will return an empty list.

Conclusion: getting information about the nearest cells on Android is a pretty dirty business at the moment. You may need a combination of all three methods to get the information you need, and even then some things may not be available.

+7
source

The following command lists the permissions available on the phone:

 adb shell pm list permissions -g 

Nexus 4 Resolution (4.2.2) does not have ACCESS_COARSE_UPDATES .

UPDATE:

When viewing the main branch of the source code, there is no link to ACCESS_COARSE_UPDATES, so it looks like an error and an error in the documentation. In fact, the corresponding code only requires ACCESS_COARSE_LOCATION and / or ACCESS_FINE_LOCATION.

Tracking the following:

  • Telephonymanager
  • ITelephony
  • PhoneInterfaceManager
  • Phoneglobals
  • Phonefactory
  • GSMPhone
  • Phonebase
  • ServiceStateTracker

In ServiceStateTracker:

 /** * @return all available cell information or null if none. */ public List<CellInfo> getAllCellInfo() { return null; } 

So it looks like in all cases it will return null.

Here is a link to the current defect report.

+5
source

The api says the following:

GetAllCellInfo preferable to using getCellLocation , although for older devices this may return null , in which case getCellLocation should be called.

-one
source

All Articles