Android 判断当前网络服务

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

判断当前网络是否是3G网络
public static boolean is3G(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
        if (activeNetInfo != null
                && activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
            return true;
        }
        return false;
    }
判断当前网络是否是wifi网络
 public static boolean isWifi(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
        if (activeNetInfo != null
                && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
            return true;
        }
        return false;
    }
判断是否有网络连接
public static boolean isConnect(Context context) {
	ConnectivityManager connectivity = (ConnectivityManager) context
		.getSystemService(Context.CONNECTIVITY_SERVICE);
	NetworkInfo activeNetInfo = connectivity.getActiveNetworkInfo();
	if (activeNetInfo != null && activeNetInfo.isConnected()) {
<span style="white-space:pre">		</span>if (activeNetInfo.getState() == NetworkInfo.State.CONNECTED) {
			return true;
		}
	}
	return false;
	}