getAllCellInfo() returns an empty list in Huawei Honor 7

假装没事ソ 提交于 2019-12-05 12:09:13

For a little work around when there is no cell in getAllCellInfo(), I use getCellLocation() to get the primaryCellId and trackingAreaCode like this:

    Log.d(TAG, "updateCurrentCell: can't find any cells with getAllCellInfo");
    CellLocation primaryLocation = telephonyManager.getCellLocation();
    if (primaryLocation != null) {
        int primaryCellId = Integer.parseInt(primaryLocation.toString().split(",")[1]);
        int trackingAreaCode = Integer.parseInt(primaryLocation.toString().split(",")[0].replace("[", ""));
    } else {
        Log.d(TAG, "updateCurrentCell: not even with getCellLocation");
    }

There are many ways to achieve CellInfo().

Some devices Doesn't support getAllCellInfo().

  1. Try telephonyManager.getNeighboringCellInfo() (This method is deprecated but still supported by some devices)

  2. To get cellinfo from that device try by building your App on SDK(API) 21.(Not recommended).

( App which are able to show all information are high likely builded and targeted on API 21 or less).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!