/**
* 判断数据连接是否可用
*
* @param context
* @return
*/
public static boolean isNetworkAvailable(Context context) {
try {
ConnectivityManager manager = (ConnectivityManager) NetworkUtils.getSystemService(context,
Context.CONNECTIVITY_SERVICE);
if (manager != null) {
NetworkInfo[] networkInfos = manager.getAllNetworkInfo();
if (networkInfos != null) {
for (NetworkInfo networkInfo : networkInfos) {
if (networkInfo != null && networkInfo.isConnected()) {
return true;
}
}
}
}
} catch (Exception e) {
}
return false;
}