public static int getwang(Context ct){ int netxt=-1; ConnectivityManager service = (ConnectivityManager) ct.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = service.getActiveNetworkInfo(); if (networkInfo==null){ return netxt; } int type = networkInfo.getType(); if (type==ConnectivityManager.TYPE_MOBILE){ netxt = 2; }else if (type==ConnectivityManager.TYPE_WIFI){ netxt=1; } return netxt; }
判断网络
最新推荐文章于 2024-02-15 17:32:46 发布