A
A
Allsir2020-05-29 19:48:59
Java
Allsir, 2020-05-29 19:48:59

How to determine signal strength in dBm in Android (Java) application?

What you need: by pressing the button , determine the signal strength of the mobile network at the moment in dBm (in extreme cases - just excellent / good / bad).

There seem to be a lot of examples on the Internet, but all of them are somehow cumbersome and incomprehensible, I can’t attach them to my program. Plus, it is not clear why several classes seem to be suitable for this at once, namely:

android.telephony.SignalStrength
android.telephony.CellSignalStrengthCdma (Gsm/Lte)
android.telephony.TelephonyManager


All these classes have a getDbm() type method.

Why there are so many options and which one is more correct to use, and most importantly, why the example code for such nonsense is so voluminous is not clear to me.

And one more thing, the getDbm () method in the specified classes is separate for each type of network (2G, 3G, LTE), maybe there is something universal to simply determine the strength, regardless of what type of network is available?

The minimum API of my application is 17.

Tell me in which direction to look at all (which class is more correct to choose and deal with) or throw in good examples, please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick, 2020-05-30
@DragonSpirit

and what is the solution from the first pages of Google, like this, not suitable for?

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

more details are in the doc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question