判断网络连接状态
时间: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;
}
}
* 判断网络连接状态
*/
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)