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 连接管理
最新推荐文章于 2019-06-27 10:21:29 发布