Back to project page cnBeta.
The source code is released under:
Apache License
If you think the Android project cnBeta listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
?package com.guest.cnbeta.util; /*from w w w . j av a2s.c om*/ import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Util { public static Boolean threadStarted = false; public static boolean isNetworkAvailable(Activity mActivity) { Context context = mActivity.getApplicationContext(); ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivity.getActiveNetworkInfo(); if (networkInfo == null || !networkInfo.isConnected()) { return false; } return true; } public static boolean isWifiConnected(Activity mActivity) { Context context = mActivity.getApplicationContext(); ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivity.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected() && networkInfo.getTypeName().equalsIgnoreCase("WIFI")) { return true; } return false; } }