determining internet speed in android

2019-07-19 04:57发布

I am developing an android video-streaming application where I must detect internet speed to adjust my stream quality according to that speed.

I've searched in the net about how to detect internet speed in android but I found only one method of downloading file and knowing its size to determine the bandwidth :

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

Is there any other possible way to determine internet bandwith in android without downloading any file I don't want to disturb my video streaming by additional file downloading

Thanks.

1条回答
SAY GOODBYE
2楼-- · 2019-07-19 05:41

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

If you are using wifi then you can calculate internet speed using WifiManager class

WifiInfo wifiInformation = wifiManger.getConnectionInfo();

and then from the WifiInfo you can get the current speed :

int speedInMbpsSpeed = wifiInformation.getLinkSpeed();

查看更多
登录 后发表回答