判断网络
程序员文章站
2022-06-05 20:39:18
...
public static boolean isNetWorkConnect(Context context){
// 获取网络管理者、
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
if (info != null){
return info.isAvailable();
}
return false;
}