Android拉动LTE RSRP值

时间:2016-08-17 12:34:39

标签: android telephonymanager cellinfo

首先,这是获取lte rsrp(或其他)值的代码。 这段代码在另一个aysncTask上运行。

 TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        int tempInt;
        while (isRunning) {
            try {
                List<CellInfo> cellInfoList = tm.getAllCellInfo();

                if (cellInfoList != null && cellInfoList.size() != 0) {
                        msg = handler.obtainMessage();
                        CellInfo cellInfo = cellInfoList.get(0);
                        result = -9999;
                        tempInt = 0;
                        if (cellInfo instanceof CellInfoWcdma) {
                            result = ((CellInfoWcdma) cellInfo).getCellSignalStrength().getDbm();
                            Log.e(TAG, "3G : " + result + "");
                        } else if (cellInfo instanceof CellInfoLte) {
                            result = ((CellInfoLte) cellInfo).getCellSignalStrength().getDbm();
                            Log.e(TAG, "LTE : " + result);
                        } else if (cellInfo instanceof CellInfoGsm) {
                            result = ((CellInfoGsm) cellInfo).getCellSignalStrength().getDbm();
                            Log.e(TAG, "GSM" + result);
                        } else if (cellInfo instanceof CellInfoCdma) {
                            result = ((CellInfoCdma) cellInfo).getCellSignalStrength().getDbm();
                            Log.e(TAG, "CDMA" + result);
                        }
.....

问题是,我不确定我得到的数据是正确

当我在背景上运行此源以查看rsrp值时,我使用命令* 123456#运行LG G3的隐藏菜单。它显示了一个显示实时rsrp值的调试模式。

问题是,我在应用程序日志上的rsrp和隐藏菜单上的那个在大多数情况下是不同的。我的应用程序显示大约-3~ + 3。

为什么会这样?我的代码有问题吗?上面的代码没有时间间隔,并且在我强行关闭应用程序之前会继续。

0 个答案:

没有答案