Android internet speed detection

I am developing an application for streaming data for Android, where I have to determine the speed of the Internet in order to adjust the quality of my stream in accordance with this speed.

I searched on the net about how to determine the Internet speed in Android, but I found only one way to download the file and knowing its size in order to determine the bandwidth:

bandwidth = contentLength / ((endTime-startTime) *1000); 

Is there any other way to determine the internet band in android without downloading any file. I do not want to disrupt streaming video when downloading additional files.

Thanks.

+2
android monitor bandwidth
source share
1 answer

If you are on 2G, 3G, 4G, I don’t think there is a standard way to find out, maybe you can automatically assume that 2G, 3G or 4G are slow.

If you use Wi-Fi, you can calculate the Internet speed using the WifiManager class.

WifiInfo wifiInformation = wifiManger.getConnectionInf about ();

and then from WifiInfo you can get the current speed:

 int speedInMbpsSpeed = wifiInformation.getLinkSpeed(); 
+1
source share

All Articles