我正在尝试在我的应用程序中获取LTE小区ID号:
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> cellInfoList = tm.getAllCellInfo();
for (CellInfo cellInfo : cellInfoList)
{
if (cellInfo instanceof CellInfoLte) {
CellIdentityLte cellIdentityLte = ((CellInfoLte) cellInfo).getCellIdentity();
cellID = cellIdentityLte.getCi();
}
}但是cellID = cellIdentityLte.getCi();总是返回2147483647,最大值表明出了问题。
我想权限ACCESS_FINE_LOCATION和READ_PHONE_STATE就足够了。play商店上的其他应用程序给了我正确的cellID,所以设备不是问题(并在几部手机上进行了测试)。顺便说一句,运行SDK v.30。
发布于 2021-04-22 17:51:01
当获取for循环中的值时,也会迭代相邻的单元,因为UE没有附加到它们,所以这些单元具有空的cid。
这里有一个解决方案:
if (cellIdentityLte.getCi() != 0 && cellIdentityLte.getCi() != 2147483647)
{
cellID = cellIdentityLte.getCi();
}https://stackoverflow.com/questions/67181525
复制相似问题