Skip to content

Instantly share code, notes, and snippets.

@granoeste
Created March 7, 2011 05:01
Show Gist options
  • Save granoeste/858096 to your computer and use it in GitHub Desktop.
Save granoeste/858096 to your computer and use it in GitHub Desktop.
[Android] Phone State Listener
public class SignalStrengthListener extends PhoneStateListener {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
boolean isGsm = signalStrength.isGsm();
// Get the CDMA RSSI value in dBm
int iCdmaDbm = signalStrength.getCdmaDbm();
// Get the CDMA Ec/Io value in dB*10
int iCdmaEcio = signalStrength.getCdmaEcio();
// Get the EVDO RSSI value in dBm
int iEvdoDbm = signalStrength.getEvdoDbm();
// Get the EVDO Ec/Io value in dB*10
int iEvdoEcio = signalStrength.getEvdoEcio();
// Get the signal to noise ratio. Valid values are 0-8. 8 is the highest.
int iEvdoSnr = signalStrength.getEvdoSnr();
// Get the GSM bit error rate (0-7, 99) as defined in TS 27.007 8.5
int iGsmBitErrorRate = signalStrength.getGsmBitErrorRate();
// Get the GSM Signal Strength, valid values are (0-31, 99) as defined in TS 27.007 8.5
int iGsmSignalStrength = signalStrength.getGsmSignalStrength();
String str = "GSM="+isGsm
+",GSM Signal Strength="+iGsmSignalStrength
+",GSM Bit Error Rate="+iGsmBitErrorRate
+",CDMA RSSI="+iCdmaDbm+"dBm"
+",CDMA Ec/Io="+iCdmaEcio+"dB*10"
+",EVDO RSSI="+iEvdoDbm+"dBm"
+",EVDO Ec/Io="+iEvdoEcio+"dB*10"
+",EVDO SNR="+iEvdoSnr
+"\n";
Log.d("SignalStrengthListener",str);
}
}
@Mandeepbhalothia
Copy link

Mandeepbhalothia commented Jun 24, 2020

onSignalStrengthsChanged() is called only once when we listen. This is not calling when the signal is changing. I faced this issue in oreo and upper os versions. Is it working fine with you, if so can you sahre implementation code and not then what you are using for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment