1 // 判断当前是否使用的是 WIFI网络
2 public static boolean isWifiActive(Context icontext){
3 Context context = icontext.getApplicationContext();
4 ConnectivityManager connectivity = (ConnectivityManager) context
5 .getSystemService(Context.CONNECTIVITY_SERVICE);
6 NetworkInfo[] info;
7 if (connectivity != null) {
8 info = connectivity.getAllNetworkInfo();
9 if (info != null) {
10 for (int i = 0; i < info.length; i++) {
11 if (info[i].getTypeName().equals("WIFI") && info[i].isConnected()) {
12 return true;
13 }
14 }
15 }
16 }
17 return false;
18 }