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.
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