转:Android检查设备是否联网
1 public static boolean isConnect(Context context) { 2 ConnectivityManager connectionManager = (ConnectivityManager) context 3 .getSystemService(Context.CONNECTIVITY_SERVICE); 4 if (connectionManager != null) { 5 NetworkInfo info = connectionManager.getActiveNetworkInfo(); 6 if (info != null && info.isConnected()) { 7 if (info.getState() == NetworkInfo.State.CONNECTED) { 8 return true; 9 } 10 } 11 } 12 return false; 13 }