华为荣耀7中getAllCellInfo()返回空列表

phu*_*win 5 android telephonymanager cellinfo

我有一个 Android 应用程序可以获取手机信号塔的信息。我使用 getAllCellInfo() 来获取主小区和相邻小区的信息。我将 ACCESS_COARSE_LOCATION 权限包含到 manifest.xml 中,并在运行时请求该权限。它适用于其他手机,但在华为荣耀7中,该函数返回一个空列表。

我的代码:
在此输入图像描述
目录: 在此输入图像描述

我检查了其他人的问题: getAllCellInfo returns null in android 4.2.1Android getAllCellInfo() returns null

从一个问题中,我想到华为手机不支持 getAllCellInfo() ,直到我安装了Network Cell Info LiteNetMonster,并且应用程序似乎可以在华为荣耀7中获取手机信息:

网络小区信息精简版
在此输入图像描述
网络怪物
在此输入图像描述

有人有这方面的信息吗?

phu*_*win 2

当 中没有单元格时getAllCellInfo(),为了解决一些问题,我使用getCellLocation()如下方式获取primaryCellId 和trackingAreaCode:

    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");
    }
Run Code Online (Sandbox Code Playgroud)