问题
How do I get the data speed of wifi/mobile network programmatically in my application.
回答1:
Here's the code for getting the WiFi speed:
WifiManager wifiManager = getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null) {
Integer linkSpeed = wifiInfo.getLinkSpeed(); //measured using WifiInfo.LINK_SPEED_UNITS
}
For mobile network speed, refer to the below link:
http://www.gregbugaj.com/?p=47
来源:https://stackoverflow.com/questions/19154992/getting-data-speed-of-wifi-mobile-network-programmatically