I have used the following code to get the signal strength,
SignalStrengthListener signalStrengthListener;
signalStrengthListener = new SignalStrengthListener();
((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).listen(
signalStrengthListener,
SignalStrengthListener.LISTEN_SIGNAL_STRENGTHS);
and then it is listening for the Signal strength,
private class SignalStrengthListener extends PhoneStateListener {
@Override
public void onSignalStrengthsChanged(
android.telephony.SignalStrength signalStrength) {
// get the signal strength (a value between 0 and 31)
int strengthAmplitude = signalStrength.getGsmSignalStrength();
// do something with it (in this case we update a text view)
// signalStrengthText.setText(String.valueOf(strengthAmplitude));
if (strengthAmplitude > 30) {
signalStrengthText.setText("Good");
// signalStrengthText.setTextColor(getResources().getColor(R.color.good));
} else if (strengthAmplitude > 20 && strengthAmplitude < 30) {
signalStrengthText.setText("Average");
// signalStrengthText.setTextColor(getResources().getColor(R.color.average));
} else if (strengthAmplitude < 20) {
signalStrengthText.setText("Weak");
// signalStrengthText.setTextColor(getResources().getColor(R.color.weak));
}
super.onSignalStrengthsChanged(signalStrength);
}
}
It works good if the sim is present in the device. But when I remove the sim from the device and then check for the signal strength, it still provides some value for the signal strength.
One possible solution, I can think of is to first check, if the sim is present in the device or not and then show the signal strength. But I would like to know an explanation for this weird behaviour and a possible solution for it.
no USIM is required for cell service - only for authentication. else emergency calls would fail.
it's not weird at all... that is common sense, since you do not remove the radio nor disable it.
a simple test: remove the USIM, call emergency services, pretend you were pocket dialing.