如何在没有单击按钮的情况下更新 wifi RSSI 值 [英] How to update wifi RSSI values without a click button

查看:38
本文介绍了如何在没有单击按钮的情况下更新 wifi RSSI 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Basically, I can list the values of RSSI in a ListView through a SimpleAdapter.

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;
    }

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

Now, I would like to know if it's possible to update the values of RSSI given by method "listaRedes" which is a List. Maybe I could call the method "listaRedes" during some time until I pause it or click in some button to pause.

有可能吗?

谢谢

推荐答案

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

Update: You can take a look at my demo for RF measurements using Android device, here:

https://github.com/panosvas/Measurements

您可以在这里找到一个接一个的 WiFi 测量实现.我还创建了一个用于存储这些测量值的服务器以及一个使用 UDP 数据包的远程触发应用程序,您可以在此处找到:

where you can find an implementation of WiFi measurements one after another. I have also created a Server for storing these measurements as well as a remote trigger app using UDP packets where you can find here:

https://github.com/panosvas/IndoorPositioningServer

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

It is possible to update your list. You can take a look in my answer here:

扫描 20 次的 Wifi 扫描仪

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

In order to adapt it to your needs you don't want the counter and instead of it, in the onRecieve each time you will trigger again the task that calls the startScan() method.

不要忘记在 onDestroy 上取消注册侦听器.

Don't forget to unregister the listener on the onDestroy.

希望这会有所帮助.

这篇关于如何在没有单击按钮的情况下更新 wifi RSSI 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆