Why cellInfo size is zero? It is zero when I get it with TelephonyManager

246 views Asked by At

I used cellInfo to get four parameters: rssi, rsrp, rsrq and sinr. I can't find right solution to solve this problem. Does anyone know how to get CellInfo? I am currently using Android Emulator. My Manifest permissions:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

Code:

TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
 cellInfoList = tm.getAllCellInfo();
        for (CellInfo cellInfo : cellInfoList) {
            if (cellInfo instanceof CellInfoLte) {
                rssi = ((CellInfoLte) cellInfo).getCellSignalStrength().getRssi();
                rsrp = ((CellInfoLte) cellInfo).getCellSignalStrength().getRsrp();
                rsrq =  ((CellInfoLte) cellInfo).getCellSignalStrength().getRsrq();
                snr = ((CellInfoLte) cellInfo).getCellSignalStrength().getRssnr();

            }
        }

    rssiValue.setText(String.valueOf(rssi));
    rsrpValue.setText(String.valueOf(rsrp));
    rsrqValue.setText(String.valueOf(rsrq));
    sinr.setText(String.valueOf(snr));
1

There are 1 answers

0
marmor On

According to the official documentation calling this method requires ACCESS_FINE_LOCATION permission, you only ask for COARSE.