How to get current cell signal strength?

后端 未结 2 767
盖世英雄少女心
盖世英雄少女心 2020-12-09 05:52

I would like to store the cell signal strength, and I do it like this:

private class GetRssi extends PhoneStateListener {
    @Override
    public void onSig         


        
2条回答
  •  时光说笑
    2020-12-09 06:22

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

提交回复
热议问题