Android Getting WiFi signal strength as it changes

主宰稳场 提交于 2019-12-21 21:35:55

问题


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 ?


回答1:


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

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

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:

Wifi Scanner which scans 20 times

How to update wifi RSSI values without a click button



来源:https://stackoverflow.com/questions/24053048/android-getting-wifi-signal-strength-as-it-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!