Code example for SignalStrength

Methods: getCdmaDbm, getEvdoDbm, getGsmBitErrorRate, getGsmSignalStrength, isGsm, toString

0
        @Override 
        public void onSignalStrengthsChanged(final SignalStrength signalStrength)
        { 
            Log.d(DEBUG_TAG, "SignalStrength changed");
            if (signalStrength != null)
                Log.d(DEBUG_TAG, signalStrength.toString());
            final int network = getNetwork();
            int strength = Integer.MIN_VALUE;
            int errorRate = 0;
             
             
            // discard signal strength from GT-I9100G (Galaxy S II) - passes wrong info 
            if (android.os.Build.MODEL != null)
            { 
                if (android.os.Build.MODEL.equals("GT-I9100G")
                    || 
                    android.os.Build.MODEL.equals("HUAWEI P2-6011"))
                return; 
            } 
             
            if (network != NETWORK_WIFI)
            { 
                if (signalStrength != null)
                { 
                    if (network == TelephonyManager.NETWORK_TYPE_CDMA)
                        strength = signalStrength.getCdmaDbm();
                    else if (network == TelephonyManager.NETWORK_TYPE_EVDO_0
                            || network == TelephonyManager.NETWORK_TYPE_EVDO_A
                    /* || network == TelephonyManager.NETWORK_TYPE_EVDO_B */) 
                        strength = signalStrength.getEvdoDbm();
                    else if (signalStrength.isGsm())
                    { 
                        final int rssi = signalStrength.getGsmSignalStrength();
                        if (rssi != 99)
                        { 
                            strength = -113 + 2 * rssi;
                            errorRate = signalStrength.getGsmBitErrorRate();
                        } 
                    } 
                    signal.set(strength);
                } 
                signals.add(new SignalItem(network, strength, errorRate, 0, 0));