public static boolean isConnect(Context context) {
ConnectivityManager connectionManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectionManager != null) {
NetworkInfo info = connectionManager.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
if (info.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
return false;
}
Android检查设备是否联网
最新推荐文章于 2024-08-26 20:49:22 发布