How do I get the data speed of wifi/mobile network programmatically in my application.
Asked
Active
Viewed 3.2k times
15
-
3Try opening a socket and download some bytes from somewhere (say 256kb) and measure how long it takes for the download to complete – Ziv Kesten Dec 24 '15 at 15:23
-
So what did you find? I want to check internet speed and set image or video url accordingly for example if internet speed is between `50kbps - 150 kbps` **link1** , `150kbps - 500kbps` **link2** and `>500kbps` **link3**. so How to achieve that? – Bhavin Patel Jun 01 '21 at 06:25
1 Answers
19
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:

Hariharan
- 24,741
- 6
- 50
- 54
-
2
-
2None-static method 'getSystemService' please help me fix this issue @Mansuu.... – Shahid Karimi May 07 '16 at 19:30
-
1pass a reference of Context whereever you have written this method to get wifi speed – Mansuu.... May 08 '16 at 08:44