public static boolean isNetworkConnected(Context context)
{
if (context != null) {
ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
if (mNetworkInfo != null) {
netConnectType = mNetworkInfo.getType();
if(netConnectType == ConnectivityManager.TYPE_WIFI)
{ //wifi
m_preConnectNetType = ConnectivityManager.TYPE_WIFI;
}
else if(netConnectType == ConnectivityManager.TYPE_ETHERNET)
{ //以太网
m_preConnectNetType = ConnectivityManager.TYPE_ETHERNET;
}
else if(netConnectType==ConnectivityManager.TYPE_MOBILE)
{ //3g网卡
m_preConnectNetType = ConnectivityManager.TYPE_MOBILE;
}
return mNetworkInfo.isAvailable();
}
}
return false;
}