判断网络连接状态

时间:2014-09-05 11:24:21   收藏:0   阅读:284
/**
* 判断网络连接状态
*/
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager cwjManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cwjManager.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
CustomizedCustomToast.makeText(mContext, "Network Available",
Toast.LENGTH_LONG).show();
return true;
} else {
CustomizedCustomToast.makeText(mContext, "Network unAvailable",
Toast.LENGTH_LONG).show();
return false;
}
}

原文:http://blog.csdn.net/tw19811220/article/details/39078113

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!