public static boolean isWiFiActive(Context inContext) {
Context context = inContext.getApplicationContext();
ConnectivityManager connectivity = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getTypeName().equals("WIFI")
&& info[i].isConnected()) {
return true;
}
}
}
}
return false;
}
ConnectivityManager 连接管理
最新推荐文章于 2024-04-18 14:05:36 发布