判断网络是否可用

1 ConnectivityManager mConnectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
2 if (mConnectivity.getActiveNetworkInfo() != null
3     && mConnectivity.getActiveNetworkInfo().isAvailable()
4     && mConnectivity.getActiveNetworkInfo().isConnected()) {
5      return true;
6 }
7 return false;

posted on 2011-07-05 16:00  还有什么  阅读(159)  评论(0)    收藏  举报

导航