Nico
Nico

Reputation: 101

Android, listing rssi values for 5 strongest wifi networks

I am trying to make a simple app that tells me the rssi values of the 5 strongest wifi networks. I don't need to connect to any of the networks, just want to know the rssi's. At the moment I'm using the following bit of code:

wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
int info = wifi.getConnectionInfo().getRssi();
textStatus.setText("WiFi Rssi: " + info);

However, this only displays the rssi value of the network I am connected to.

Is there a way of getting this information for other networks?

Upvotes: 5

Views: 7286

Answers (1)

Nico
Nico

Reputation: 101

I think I got it:

ScanResult result0 = wifi.getScanResults().get(0);
String ssid0 = result0.SSID;
int rssi0 = result0.level;
String rssiString0 = String.valueOf(rssi0);
textStatus.append("\n" + ssid0 + "   " + rssiString0);

then get(1), get(2) and so on for however many you like

Upvotes: 5

Related Questions