Getting data speed of wifi/mobile network programmatically [duplicate]

这一生的挚爱 提交于 2019-11-26 20:00:59

问题


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

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