package com.zhimai.websocket.util;

import android.content.Context;
import android.net.ConnectivityManager;

/**
 * Explain：
 * Created on 2020/9/25.
 *
 * @author zhangshenglong
 */
public class NetWorkUtils {
    public static boolean isOnline(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        if (cm == null) {
            return false;
        }
        if (cm.getActiveNetworkInfo() == null) {
            return false;
        }
        return cm.getActiveNetworkInfo().isAvailable();
    }

    public static boolean isOffline(Context context) {
        return false==isOnline(context);
    }
}
