![](/img/trans.png)
[英]How to achieve dialogue box get disappeared when internet or WiFi get connected. and vice versa?
[英]Get Internet state change while wifi is connected
我想知道是否有任何意图或广播在始终连接wifi /数据网络时通知Internet连接/断开时。 我知道CONNECTIVITY_CHANGE,但它仅在打开/关闭wifi /数据时通知。
谢谢
就我而言,此代码块工作正常,您必须尝试一下
public boolean isInternetAvailable() {
try {
InetAddress ipAddress = InetAddress.getByName("google.com");
//You can replace it with your name
return !ipAddress.equals("");
} catch (Exception e) {
return false;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.