Getting signal strength

Jack iPhone picture Jack iPhone · May 10, 2012 · Viewed 9.7k times · Source

I want to know how to get CDMA / GSM signal strength using Android.

Note : I used getCdmaDbm() method but it always returns -1.

Answer

ρяσѕρєя K picture ρяσѕρєя K · May 10, 2012

use PhoneStateListener 's onSignalStrengthsChanged for getting SignalStrength:

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(srvcName);  
AndroidPhoneStateListener phoneStateListener = new AndroidPhoneStateListener (this);  
telephonyManager.listen(phoneStateListener,      
PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
    public class AndroidPhoneStateListener extends PhoneStateListener {
        public static int signalStrengthValue;

        @Override
        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 {
                signalStrengthValue = signalStrength.getCdmaDbm();
            }
        }

    }

Permission :

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