[英]Get Internet state change while wifi is connected
I want to know if there is any intent or broadcast that notifies when internet is connected/disconnected while the wifi/data network is connected all the time. 我想知道是否有任何意图或广播在始终连接wifi /数据网络时通知Internet连接/断开时。 I am aware of CONNECTIVITY_CHANGE but it only notifies when wifi/data is switched on/off. 我知道CONNECTIVITY_CHANGE,但它仅在打开/关闭wifi /数据时通知。
Thanks 谢谢
In my case this block of code is working fine, you must try it 就我而言,此代码块工作正常,您必须尝试一下
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.