Android判断是否有网络连接
private boolean isNetWorkAvaiable() { ConnectivityManager manager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if(networkInfo!=null){ return networkInfo.isAvailable(); }else{ return false; } }