wifi getLinkSpeed() return a value always

自古美人都是妖i 提交于 2019-12-20 05:53:47

问题


I am developing an application that displays internet speed. like: https://play.google.com/store/apps/details?id=netspeed.pt

https://play.google.com/store/apps/details?id=com.internet.speed.meter.lite&hl=en

I have to gain WiFi speed at any moment, I used the runnable:

WifiManager wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wm.getConnectionInfo();
....

runnable = new Runnable() {

    @Override
    public void run() {

        int linkSpeed = wifiInfo.getLinkSpeed();
        chatHead.setText( "Speed : " + linkSpeed);
        handler.postDelayed(runnable,100); 

    }
};

handler.postDelayed(runnable,100); 

But speed does not changes , even when downloading. I'm a little confused!

I have access to the Internet at any given moment, what can I do? Should be used from native code? Or Java code as well?

Please help me.


回答1:


The link speed is the maximum protocol speed between your device and the wifi base station.

If you want to measure actual amount of data transferred over a time period, have a look at TrafficStats.



来源:https://stackoverflow.com/questions/26669654/wifi-getlinkspeed-return-a-value-always

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