android中检查是否联网code
直接贴判断代码了额:
?
? ? private boolean isNetworkAvailable() {
ConnectivityManager connManager = (ConnectivityManager) this .getSystemService(CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isAvailable(); } else return false;}?