I want to detect if a phone has a slow internet connection or high-speed internet.
Now they have deprecated NetworkInfo
and suggesting that we should use ConnectivityManager#getNetworkCapabilities
using this I am able to get the signal strength but not able to figure out how to use integer value returned by networkCapabilities.getSignalStrength()
It is returning an Integer value I am getting these values (-39, -71, -31).
My question is how should we define that signal strength is good/poor.
Here is my code to get Signal Strength:
ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
Network activeNetwork = cm.getActiveNetwork();
NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(activeNetwork);
int signalStrength = networkCapabilities.getSignalStrength();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…