I'm trying to detect signal strength changes in a wifi connection. I'm confused of which method I should use in my BroadcastReceiver. What is the difference between using getConnectionInfo() and getScanResults() - from which then I can use relevant method to get the rssi value?
For example: if I use getConnectionInfo(), then later on I use getRssi(). Or I could use getScanResults() and the "level" property.
I display their values using Toast and it doesn't always show same values. When wifi conn is lost, the getConnectionInfo().getRssi() shows -200, while result.level still shows its previous value.
Any thoughts? Thanks!
String netSSID = wifi.wifiMgr.getConnectionInfo().getSSID();
int netRSSI = wifi.wifiMgr.getConnectionInfo().getRssi();
List<ScanResult> results = wifi.wifiMgr.getScanResults();
for (ScanResult result : results) {
if (result.SSID.equalsIgnoreCase(netSSID)) {
anothernetRSSI = result.level;
}
}