Hey I tried for signalStrength.getGsmSignalStrength() for GSM and CDMA devices but I noticed that both the devices gives strength even when sim is not inserted in device.I want to place a call or send message only if network is good how can I achieve this? And also want to know which signal strength this API returns!!... Please reply as soon as possible.
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();
}
}
}
i believe this may help you to detect Sim card availability:
moreover, you may read this
Your phone connects to the cellular network even when you don't have a SIM inserted, provided airplane mode is off, so that emergency calls can be made. Cell operators are required by law to allow such calls. So they allow phones without SIM to register on their network and your phone goes in Emergency Calls Only mode. That's why you read signal strength values with no SIM.