Android获取随其变化的WiFi信号强度 [英] Android Getting WiFi signal strength as it changes

查看:133
本文介绍了Android获取随其变化的WiFi信号强度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得所连接的WiFi网络的信号强度,因为它会发生变化. 这是我的广播接收器

I want to get the Signal strength of the WiFi network I am connected to , as it changes . This is my broadcast receiver

     registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            int info = Wifi.getConnectionInfo().getRssi();
            textStatus.append("\n\n : " + Integer.toString(info));
        }
    }, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));

我只得到一次.我如何获得它的变化?

I am getting it only once . How do i get it as it changes ?

推荐答案

更新:从Android 4.4和5.0进行的测试来看,连续WiFi扫描之间的间隔似乎不到一秒钟.您可以在这里查看我的使用Android设备进行射频测量的演示:

Update: From tests in Android 4.4 and 5.0 the interval between sequential WiFi scans seems to be less than a second. 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

实际上,您不能每次都更改RSSI,因为RSSI值可能会在几毫秒甚至更快的时间内发生变化,并且Android中的每一次wifi测量大约需要5秒钟,具体取决于设备.

Actually, you cannot take the RSSI each time it changes because it is possible that the RSSI value changes in a period of mseconds or even faster and each wifi measurement in Android takes approximately 5 seconds depending also on the device.

因此,您在以下文章中对我的建议有何建议?

So, what you advice my answers in the following posts for that:

可扫描20次的Wifi扫描器

如何无需单击即可更新wifi RSSI值按钮

这篇关于Android获取随其变化的WiFi信号强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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