Kris Kris - 1 year ago 169
Android Question

issue with wifimanager.calculatesignalstrenth

I am using the following code to calcualte wifi signals strength:

List<ScanResult> results = wifiDemo.wifi.getScanResults();

for(int i=0;i<results.size();i++)
int signallevel=WifiManager.calculateSignalLevel(result.level,10);

But it is returning the same value for all the wifi acess points. Can anyone please tell me what I'm doing wrong?

Answer Source

You should keep in mind that WifiManager.calculateSignalLevel(result.level, 10) will return only a number between 0-9. Therefore it is best used for some app which shows a wifi strength indicator (with a few different states like the one normal WiFi indicator in android). Which number is returned depends on the RSSI parameter. So even if the RSSI of two access points are slightly different, this method will yield the same result. If you need finer distinguished results, use either a number higher than 10 or the RSSI values themselves.