android – 用于CDMA设备的dbm中的signalStrength的范围

前端之家收集整理的这篇文章主要介绍了android – 用于CDMA设备的dbm中的signalStrength的范围前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在检查CDMA设备的信号强度.任何人都可以指定范围signalStrength.getCdmaDbm()返回?最低是-120但对于全信号强度有什么价值?最高我是-52.

解决方法

那么我不知道这是你正在寻找什么,但在看了在 Android代码的SignalStrength.java文件后,我注意到一些代码有一堆cdma dbm和ecio级别的级别.
DBM 
level 4 >= -75
level 3 >= -85
level 2 >= -95
level 1 >= -100

Ecio 
level 4 >= -90
level 3 >= -110
level 2 >= -130
level 1 >= -150

而水平是两者中最低的

actualLevel = (levelDbm < levelEcio) ? levelDbm : levelEcio;

但是我注意到这与通知显示的实际条不相关.如果在3G中,则忽略该级别,并使用信噪比.

signalStrength.getEvdoSnr() // value is 0 to 8 so divide by two to get the bars

如果数据从3G下降到1x,则使用actualLevel.

这是我的代码找到显示数量吧.

public void onSignalStrengthsChanged(SignalStrength signalStrength) {
        super.onSignalStrengthsChanged(signalStrength);
        if (signalStrength.isGsm()) {
            if (signalStrength.getGsmSignalStrength() != 99)
                signalStrengthValue = signalStrength.getGsmSignalStrength() * 2 - 113;
            else
                signalStrengthValue = signalStrength.getGsmSignalStrength();
        } else {
            final int snr = signalStrength.getEvdoSnr();
            final int cdmaDbm = signalStrength.getCdmaDbm();
            final int cdmaEcio = signalStrength.getCdmaEcio();
            int levelDbm;
            int levelEcio;
            int level = 0;

            if (snr == -1) {
                if (cdmaDbm >= -75) levelDbm = 4;
                else if (cdmaDbm >= -85) levelDbm = 3;
                else if (cdmaDbm >= -95) levelDbm = 2;
                else if (cdmaDbm >= -100) levelDbm = 1;
                else levelDbm = 0;

                // Ec/Io are in dB*10
                if (cdmaEcio >= -90) levelEcio = 4;
                else if (cdmaEcio >= -110) levelEcio = 3;
                else if (cdmaEcio >= -130) levelEcio = 2;
                else if (cdmaEcio >= -150) levelEcio = 1;
                else levelEcio = 0;

                level = (levelDbm < levelEcio) ? levelDbm : levelEcio;
            } else {
                if (snr == 7 || snr == 8) level =4;
                else if (snr == 5 || snr == 6 ) level =3;
                else if (snr == 3 || snr == 4) level = 2;
                else if (snr ==1 || snr ==2) level =1;

            }

            text.setText("Bars= " + level);


        }
    }

在on创建方法中使用以下,并确保清单使用READ_PHONE_STATE.

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    AndroidPhoneStateListener phoneStateListener = new AndroidPhoneStateListener(text);
    telephonyManager.listen(phoneStateListener,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
原文链接:https://www.f2er.com/android/310915.html

猜你在找的Android相关文章