static ConnectivityManager mConnectivityManager;
/**
* 判断网络是否可用
*
* @param context
* @return
*/
public static boolean isNetworkAvailed(final Context context)
{
if (context == null)
{
return false;
}
if (mConnectivityManager == null)
{
mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
}
NetworkInfo info = mConnectivityManager.getActiveNetworkInfo();
if (info != null)
{
return info.isConnected();
}
return false;
}