判断网络是否可用的方法

126 阅读1分钟

                    private static boolean isNetAvailable(Context context){
                        ConnectivityManager manager= (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
                        NetworkInfo info=manager.getActiveNetworkInfo();
                        return info== null ? false:true;
                    }