我对Android编程非常陌生,到目前为止我已经玩得很开心。我在使用电话管理器时遇到了一个问题,特别是LTE。我的getCi()方法返回一个值,它是正确的,但不是我需要的格式。例如,返回值为25605。我可以使用什么代码来获取这个数字并创建正确的Node B ID和Cell ID值,这是我希望我的应用程序显示的内容?
TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
List<CellInfo> cellInfos = tm.getAllCellInfo();
for(CellInfo cellInfo : cellInfos)
{
//CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
CellInfoLte cellInfoLte = (CellInfoLte)cellInfo;
//CellInfoGsm cellInfoGsm = (CellInfoGsm)cellInfo;
//CellIdentityWcdma cellIdentityWcdma = cellInfoWcdma.getCellIdentity();
//CellSignalStrengthWcdma cellSignalStrengthWcdma = cellInfoWcdma.getCellSignalStrength();
CellIdentityLte cellIdentityLte = cellInfoLte.getCellIdentity();
CellSignalStrengthLte cellSignalStrengthLte = cellInfoLte.getCellSignalStrength();
netId = cellIdentityLte.getCi();
netId2 = cellSignalStrengthLte.getLevel();
//netId = cellIdentityWcdma.getCid() & 0xffff;
//netId2 = cellSignalStrengthWcdma.getAsuLevel();
//netId3 = netId2*2 -113;在此处输入代码
发布于 2017-12-07 00:14:10
必须转换为十六进制的cellIdentityLte.getCi()的值。
然后最后两个符号转换为DEC,这是本地小区ID。
剩下的(除了最后两个符号)你转换成DEC,这就是eNodeB。
我不知道Java,但这里有Excel公式。我想你会明白其中的逻辑
eNodeB =HEX2DEC(LEFT(DEC2HEX(E2),LEN(DEC2HEX(E2))-2))
Local_Cell_ID =HEX2DEC(RIGHT(DEC2HEX(E2),2))其中E2是cellIdentityLte.getCi()的输出
我已经对此进行了测试,并检查了电池配置。这些值是相同的。
https://stackoverflow.com/questions/45350558
复制相似问题