计算互联网传输速度的机器人 [英] Calculating Internet Speed in android
问题描述
我正与其中包含Web服务的东西的应用程序。
I am working with an App which contains web service things.
在我需要知道的状态时,上网速度较低。如何找到在Android的上网速度等级?
In that I need to know the status when the Internet speed is low. How to find the internet speed level in Android?
例如,考虑一下,如果我用我的手机2Mbps的连接,当它减慢至50Kbps,我需要通过一个烤面包或警报注意到这种情况。
For example, Consider if I am using 2Mbps connection in my cell phone and when it slows to 50Kbps I need to notice that situation by making a Toast or Alert.
感谢。
推荐答案
如果您已连接到无线
你可以找到连接的使用速度<一href="http://developer.android.com/reference/android/net/wifi/WifiManager.html"><$c$c>WifiManager$c$c>
If you are connected to WiFi
you can find the speed of the connection using WifiManager
:
WifiInfo wifiInfo = wifiManger.getConnectionInfo();
和然后从<一个href="http://developer.android.com/reference/android/net/wifi/WifiInfo.html#getLinkSpeed%28%29"><$c$c>WifiInfo$c$c>你可以得到当前速度:
and then from the WifiInfo
you can get the current speed :
int speedMbps = wifiInfo.getLinkSpeed();
如果您使用的是3G,我不觉得有什么查不到,也许你可以自然而然地认为3G是缓慢的标准方法。
If you are on 3G, I don't think there is a standard way of finding out, maybe you can assume automatically that 3G is slow.
这篇关于计算互联网传输速度的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!