Skip to content Skip to sidebar Skip to footer

Get Cellsignalstrength From Neighboringcellinfo

i need to get signal level from CellSignalStrength.getLevel() i take it from CellInfoGsm by TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHON

Solution 1:

i solved it - i guess i do - by rewrite getLevel() function from CellInfoGsm

i call NeighboringCellInfo.getRssi() and then convert it to level, like CellInfoGsm.getLevel() do it

for(NeighboringCellInfo nci:telephonyManager
                    .getNeighboringCellInfo()){
                if(neighborCellInfo == null) {
                    neighborCellInfo = nci;
                } elseif(nci.getRssi() > neighborCellInfo.getRssi()) {
                    neighborCellInfo = nci;
                }
            }

            int level;

            int GSM_SIGNAL_STRENGTH_GREAT = 12;
            int GSM_SIGNAL_STRENGTH_GOOD = 8;
            int GSM_SIGNAL_STRENGTH_MODERATE = 8;

            // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5// asu = 0 (-113dB or less) is very weak// signal, its better to show 0 bars to the user in such cases.// asu = 99 is a special case, where the signal strength is unknown.int asu = neighborCellInfo.getRssi();
            if (asu <= 2 || asu == 99) level = 0;
            elseif (asu >= GSM_SIGNAL_STRENGTH_GREAT) level = 4;
            elseif (asu >= GSM_SIGNAL_STRENGTH_GOOD)  level = 3;
            elseif (asu >= GSM_SIGNAL_STRENGTH_MODERATE)  level = 2;
            else level = 1;

Post a Comment for "Get Cellsignalstrength From Neighboringcellinfo"