在Android中确定互联网速度 [英] determining internet speed in android

查看:109
本文介绍了在Android中确定互联网速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个android视频流应用程序,在该应用程序中,我必须检测互联网速度以根据该速度调整流质量.

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

我已经在网上搜索了如何在android中检测互联网速度,但是我发现只有一种下载文件并知道其大小以确定带宽的方法:

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

是否还有其他方法可以确定android中的互联网带宽,而无需下载任何我不希望通过其他文件下载来干扰我的视频流的文件

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

谢谢.

推荐答案

如果您使用的是2G,3G,4G,我认为没有标准的查找方法,也许您可​​以自动假设2G,3G或4G速度很慢.

如果您使用的是wifi,则可以计算互联网速度 使用 WifiManager类

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

WifiInfo wifiInformation = wifiManger.getConnectionInfo();

,然后从WifiInfo中获取当前速度:

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

int speedInMbpsSpeed = wifiInformation.getLinkSpeed();

这篇关于在Android中确定互联网速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆