/**
* 检查网络是否连接
* @return
*/
private boolean checkedNetwork() {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mobNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (!mobNetworkInfo.isConnected() && !wifiNetworkInfo.isConnected()) {
ToastUtils.showToast(context, "你已经进入没有网络的异次元世界");
return false;
}
return true;
}
网友评论