开发者

RSSI measures in Android!!updating it from Wifi scan results!!how to?

开发者 https://www.devze.com 2023-02-18 20:14 出处:网络
I\'m doing this app were I get the RSSI measurements from previous choosen APs (whch are retrieved in the \"recebidos\" variable stated in the code bellow!), but after the scan in broadcast receive th

I'm doing this app were I get the RSSI measurements from previous choosen APs (whch are retrieved in the "recebidos" variable stated in the code bellow!), but after the scan in broadcast receive the application is not updating the RSSI value, it is just returning the previous value all the time!!! What is wrong in this code, can't I use getScanResults with the WifiManager.SCAN_RESULTS_AVAILABLE_开发者_StackOverflowACTION?

Please help me...

private final BroadcastReceiver wifiReceiver = new BroadcastReceiver()
        {
      @Override
      public void onReceive(Context ctx, Intent intent)
      {
          listaAP=wifiManager.getScanResults();


          recebidos=nivel.split("SP1");

          StringBuffer scanList = new StringBuffer();
          if (listaAP != null) {
              for (int i = listaAP.size() - 1; i >= 0; i--) {
                  final ScanResult scanResult = listaAP.get(i);

                  if (scanResult == null) {
                      continue;
                  }

                  if (TextUtils.isEmpty(scanResult.BSSID)) {
                      continue;
                  }

                  scanList.append("SP1ID:"+scanResult.BSSID+"RSSI"+scanResult.level);

                  }

              results=scanList.toString().split("SP1");

              for(int z=0;z<results.length;z++)
              {
                  for(int x=0;x<recebidos.length;x++)
                  {
                  if(results[z].compareTo(recebidos[x])==0)
                  {
                      textRssi.append(results[z]);
                  }

                  }
              }

                   }}};


You should call android.net.wifi.WifiManager.startScan() or startScanActive() to force another scan - it won't update the data unless you'll call this periodically.

0

精彩评论

暂无评论...
验证码 换一张
取 消