Get Signal Strength in Android

Get signal strength of WIFI and Mobile Data

Wifi:

WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
int linkSpeed = wifiManager.getConnectionInfo().getRssi();

In case of mobile it should work:

TelephonyManager telephonyManager =        (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
CellInfoGsm cellinfogsm = (CellInfoGsm)telephonyManager.getAllCellInfo().get(0);
CellSignalStrengthGsm cellSignalStrengthGsm = cellinfogsm.getCellSignalStrength();
cellSignalStrengthGsm.getDbm();

Then You should compare this signal levels and if WIFI signal is better keep it turn on, but if mobile is better disconnect wifi

How to get signal strength android?

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.

How to get current cell 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();

How to get cell service signal strength in Android?

create a PhoneStateListener and handle the onSignalStrengthChanged callback. When your app is initialized, it should give you an initial notification. This is in 1.x. in 2.x, there's an open issue about this.

How to get signal strength of connected WiFi android?

Hope it works..

public void onReceive(WifiManager wifiManager) {
int numberOfLevels=5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level=WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
System.out.println("Bars =" +level);
}


Related Topics



Leave a reply



Submit