Getting data speed of wifi/mobile network programmatically

Ullas picture Ullas · Oct 3, 2013 · Viewed 29.4k times · Source

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

Answer

Hariharan picture Hariharan · Oct 3, 2013

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