简体   繁体   English

Android检查低连接模式Wifi或数据网络

[英]Android check low connectivity mode Wifi or Data network

I have read quite alot of posts on Checking internet connection. 我已经阅读了很多有关检查互联网连接的帖子。 But my problem is how do I detect limited and/or low connectivity? 但是我的问题是如何检测到有限和/或低连接性? Pinging google.com continously is not the answer. 不能持续对google.com进行ping操作。 A possible solution is keep on checking RSSI Strength and if the value goes higher then lets say -70 then we check for connection. 一个可能的解决方案是继续检查RSSI强度,如果该值变高,则说-70,然后我们检查连接。

Has anyone a better solution as how to detect limited connectivity? 有谁有更好的解决方案来检测有限的连通性?

You can take a look at Determining and Monitoring the Connectivity Status . 您可以查看确定和监视连接状态 There is an example how to determine the internet connection and how to determine the type of a connection. 有一个示例如何确定Internet连接以及如何确定连接类型。

You could also take a look at android.net.conn.CONNECTIVITY_CHANGE broadcasts. 您还可以查看android.net.conn.CONNECTIVITY_CHANGE广播。

I have looked for an answer to this on one of my projects rather extensively. 我在我的一个项目中一直在寻找答案。 All that I could suggest is to ping google and then get the response time. 我所建议的只是对google ping,然后获得响应时间。 You could create your own method of comparison like, response >= 500ms = slow connection. 您可以创建自己的比较方法,例如,响应> = 500ms =慢速连接。

You could also detect whether or not the device is on 2G/3G and depending on what you consider slow. 您还可以根据您认为较慢的速度检测设备是否在2G / 3G上。

Lastly, if you can check if the wifi connection speed using the following: (I haven't used this myself) 最后,如果您可以使用以下方法检查wifi连接速度:(我自己没有使用过)

WifiInfo wifiInfo = wifiManger.getConnectionInfo();
int mbps = wifiInfo.getLinkSpeed();

I really hope that helps mate, happy coding. 我真的希望对您有所帮助,并为您编写愉快的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM