Question

I am trying to loop over the results of wifiManager scan of access points to return the RSSI strength (dbm). What I have so far:

public class MyWifiReceiver extends BroadcastReceiver {

      @Override
      public void onReceive(Context context, Intent intent) {
          WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
          boolean a= wifiManager.startScan();//request a scan for access points
          List<ScanResult> results= wifiManager.getScanResults();
      }
 }
Was it helpful?

Solution

public class MyWifiReceiver extends BroadcastReceiver {

      @Override
      public void onReceive(Context context, Intent intent) {
          final WifiManager lWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
          boolean a= lWifiManager.startScan();//request a scan for access points
          final List<ScanResult> lResults= lWifiManager.getScanResults();
          for(final ScanResult lScanResult : lResults){
            System.out.println("ScanResult level: "+lScanResult.level);
          }       
       }
}

should do what you need. As far as I see level is a public class member of ScanResult.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top