Getting data speed of wifi/mobile network programm

2019-01-13 22:41发布

This question already has an answer here:

How do I get the data speed of wifi/mobile network programmatically in my application.

1条回答
够拽才男人
2楼-- · 2019-01-13 23:09

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

查看更多
登录 后发表回答