0

基本上,我可以通过 SimpleAdapter 在 ListView 中列出 RSSI 的值。

public class ActivityListarRedes extends MainActivity {


@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listar_redes);


    List<Map<String, String>> l = listaRedes();


    String[] from = { "ExampleId", "ExampleName" };
    int[] to = { android.R.id.text1, android.R.id.text2 };

    SimpleAdapter ad = new SimpleAdapter(this, l, simple_list_item_2, from, to);
    ListView lv = (ListView) findViewById(R.id.list);
    lv.setAdapter(ad);




}

public List<Map<String, String>> listaRedes() {

        networks = new ArrayList<ScanResult>();
        wifi.startScan();
        networks = wifi.getScanResults();

        List<Map<String, String>> l = new ArrayList<Map<String, String>>();

        for (ScanResult net : networks) {
            Map<String, String> m = new HashMap<String, String>();
            m.put("ExampleId", "Rede: " + net.SSID);
            m.put("ExampleName", "RSSI: " + net.level + "dBm");
            l.add(m);
        }
        return l;
    }

现在,我想知道是否可以更新由“listaRedes”方法给出的 RSSI 值,该方法是一个列表。也许我可以在一段时间内调用方法“listaRedes”,直到我暂停它或单击某个按钮暂停。

这可能吗?

谢谢

4

1 回答 1

0

更新:您可以在此处查看我的使用 Android 设备进行射频测量的演示:

https://github.com/panosvas/Measurements

您可以在其中找到一个接一个地执行 WiFi 测量的方法。我还创建了一个用于存储这些测量值的服务器以及一个使用 UDP 数据包的远程触发应用程序,您可以在此处找到:

https://github.com/panosvas/IndoorPositioningServer

可以更新您的列表。您可以在这里查看我的答案:

扫描 20 次的 Wifi 扫描仪

为了使其适应您的需要,您不需要计数器,而是在 onRecieve 中,每次您将再次触发调用 startScan() 方法的任务。

不要忘记在 onDestroy 上取消注册监听器。

希望这可以帮助。

于 2014-11-27T11:18:52.727 回答