I would like to store the cell signal strength, and I do it like this:
private class GetRssi extends PhoneStateListener {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
Variables.signal = signalStrength.getGsmSignalStrength();
}
}
Okay but this only runs if it changes. I need the current signal strength.
Is there a method to just ask for the current signal strength?
There is getAllCellInfo() method in TelephonyManager added in API 17 that could be good solution. Example of use:
TelephonyManager telephonyManager = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
// for example value of first element
CellInfoGsm cellInfoGsm = (CellInfoGsm)telephonyManager.getAllCellInfo().get(0);
CellSignalStrengthGsm cellSignalStrengthGsm = cellInfoGsm.getCellSignalStrength();
cellSignalStrengthGsm.getDbm();