如何在android中找到GPRS/3G网络数据传输速度?
在我的应用程序中,我需要找到连接网络的速度(wifi/GPRS/3G)。在这里我需要帮助来确定 GPRS/3G 网络的速度。你能帮我解决这个问题吗?
in my application i need to find the speed of connected network (wifi/GPRS/3G). Here i need help to find the speed of GPRS/3G network. Can you please help me how to solve this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这也不是一个完整的答案,但对于 Wifi 网络(非蜂窝网络),您可以通过以下方式获取链接速率:
需要注意的一些事项:
android.permission.ACCESS_WIFI_STATE 权限。
This isn't a complete answer either, but for Wifi networks (not cellular), you can get the link rate through something like the following:
A few things to note:
android.permission.ACCESS_WIFI_STATE
permission.TrafficStats 将完成这项工作。您可以获取传输的字节数,然后可以计算速度。
TrafficStats will do the work. You can get bytes transferred, then you can calculate the speed.
也许可以弄清楚,该用户已连接到 wifi、gprs 或 g3 网络。
然后你就可以算出每种技术的速度有多快。您也可以将文件(例如 3MB)放在快速连接服务器上。然后您可以下载该文件并测量时间,即需要多长时间。然后只需计算...或者您可以在文件下载时每秒计算一次。
此外,下载速度可能因不同条件而异。比如网络强度(展位无线和移动)。例如,如果用户连接到 54mbit wifi,并且接入点距用户 60 米,那么下载速度甚至不会是其一半。
这是下载速度计算的示例 java 如何计算 Mbit/s while循环下载
maybe it is possible to figure out, that user is connected to wifi, gprs, or g3 network.
Then you can figure out how fast is each technology. Also you can put file (for example 3MB) on fast connection server. Then you can download that file and measure time, how long it takes. Then just calculate... Or You can calculate it after each second while file is downloading.
Also download speed may vary from various conditions. Like network strength (booth wireless and mobile). For example, if user is connected to 54mbit wifi and access point is 60 meters form user, then download speed wont be even half of that.
Here is example with download speed calculations java howto calculate Mbit/s during while loop download
看看 Zwitscher NetworkHelper 类
基本上你需要获取
ConnectivityManager
,然后查询您想了解的内容。
有关详细信息,请浏览上面的类以查看
type
和subType
的含义。Have a look at Zwitscher's NetworkHelper class
Basically you need to obtain the
ConnectivityManager
and then query this for what you want to know
For more info, browse the above class to see the meanings of
type
andsubType
.