Android 判断当前网络是否为wifi网络

public static boolean isWifiActive(Context context) {
		Context context2 = context.getApplicationContext();
		ConnectivityManager manager = (ConnectivityManager) context2
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo[] info;
		if (manager != null) {
			info = manager.getAllNetworkInfo();
			if (info != null) {
				for (int i = 0; i < info.length; i++) {
					if ("WIFI".equals(info[i].getTypeName())
							&& info[i].isConnected()) {
						return true;
					}
				}
			}
		}
		return false;
	}

你可能感兴趣的:(网络,wifi)