Search code examples
androidsignal-strength

How to get signal strength android?


CellSignalStrength is the closest to what i need, but the problem i'm facing is that there is no constructor to use the class, and I tried to make a new class and extend it, it didn't work, the android documentation is good, without offering one small piece of code to follow, I don't know what to do.

i'm using API 8, which doesn't support that class, what should I do ?


Solution

  • TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    List<CellInfo> all = telephonyManager.getAllCellInfo();
    CellInfoGsm cellinfogsm = (CellInfoGsm) all.get(0);
    CellSignalStrengthGsm cellSignalStrengthGsm = cellinfogsm.getCellSignalStrength();
    int strengthDbm = cellSignalStrengthGsm.getDbm();
    

    should work fine for API 17+. I am not aware of any API to help <17, though.