Device showing signal Strength if there is no sim

I 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 he listens to the strength of the signal,

 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); } } 

This works well if the sim is present on the device. But when I remove the simulator from the device, and then check the signal level, it still gives some value for the signal strength.

One of the possible solutions that I can think of is to first check if the SIM device is present in the device or not, and then show the signal strength. But I would like to know an explanation of this strange behavior and a possible solution for it.

+4
source share

All Articles