public class NetworkUtils {
public static boolean isNetWorkConnected(Context context) {
// 判断网络连接是否可用
if (context != null) {
ConnectivityManager manager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = manager.getActiveNetworkInfo();
if(networkInfo != null){
return networkInfo.isAvailable();
}
}
return false;
}
}
Android判断网络连接是否可用【从新浪云搬运】
最新推荐文章于 2017-10-18 19:22:58 发布