Search code examples
androidandroid-layoutandroid-wifi

Visualize the wifi signal strength


I was able to scan all wifi networks with the wifimanager.getScanResults(). In the next step I extracted the SSID and signal level of the wifi network.

private List<String> showOnlySSIDAndLevel(List<ScanResult> networks) {
    List<String> networkList = new ArrayList<String>();
    for(ScanResult result : networks){
        int level = WifiManager.calculateSignalLevel(result.level, 5) + 1;
        String content = result.SSID + " \tSignal strength: " + level;
        networkList.add(content);
    }
    return networkList;
}

I have the signal level in a format, where it's between 1 - 5 (5 is the best signal level) How can I use this to have a graphical representation of the different wifi signal levels. I coudn't find a UI for this. Do I need a graphic for each of the 5 possible level or is there another way? How is the internal Android Settings (Wifi scan results) doing it?


Solution

  • You can use the built-in RatingBar component. You can make it read-only by giving it a ratingBarStyleSmall or ratingBarStyleIndicator style.