I want to detect a situation where the user is somewhere with low reception (low network signal) for an amount of time (5 minutes for example), and I am wondering what value to rely on.
What I have now is:
public class RadiationTest {
TelephonyManager TelephonManager;
SignalStrengthListener signallistener;
private Context context;
public RadiationTest(Context context) {
this.context = context;
try {
signallistener = new SignalStrengthListener();
TelephonManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
TelephonManager.listen(signallistener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
} catch (Exception ex) {
ex.printStackTrace();
}
}
class SignalStrengthListener extends PhoneStateListener {
@Override
public void onSignalStrengthsChanged(android.telephony.SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
int SignalStrength_ASU = signalStrength.getGsmSignalStrength();
int SignalStrength_dBm = (2 * SignalStrength_ASU) - 113; // -> dBm
// here I can use dbm
// I can also get the bars with signalStrength.getLevel()
}
}
}
Looking at the dbm values - it seems that its 85 most of the time - which means good reception, and when going to a place with low reception, its getting negative values. from this answer I learned that negative values for dbm means that the reception is low - but its not negative, it just means your device is very sensitive. (see table in answer).
Also, the dbm values seem to change from device to device.
Looking at the signalStrength.getLevel()
, it gives you how many reception bars are there, and it looks like a good option.
With that in mind, SignalStrength
is a class with a lot of values, and I was just wondering what is the most reliable way to test for low signal for some amount of time and to see if people have some experience with this.