以编程方式获取wifi /移动网络的数据速度

Ull*_*las 13 mobile networking android android-wifi

如何在我的应用程序中以编程方式获取wifi /移动网络的数据速度.

Har*_*ran 20

以下是获取WiFi速度的代码:

WifiManager wifiManager = getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null) {
    Integer linkSpeed = wifiInfo.getLinkSpeed(); //measured using WifiInfo.LINK_SPEED_UNITS
}
Run Code Online (Sandbox Code Playgroud)

有关移动网络速度,请参阅以下链接:

http://www.gregbugaj.com/?p=47

  • 也许它可以提供最大的速度。 (2认同)
  • 非静态方法'getSystemService'请帮我解决这个问题@Mansuu .... (2认同)