determining internet speed in android

自闭症网瘾萝莉.ら 提交于 2019-12-24 04:24:09

问题


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:


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();



来源:https://stackoverflow.com/questions/16334020/determining-internet-speed-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!