Android 判断当前是否在WIFI网络下
2019-07-26 本文已影响0人
Cedric_h
原文:https://blog.csdn.net/uyy203/article/details/72822414
private static boolean isWifi(Context mContext) {
ConnectivityManager connectivityManager = (ConnectivityManager) mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info= connectivityManager.getActiveNetworkInfo();
if (info!= null
&& info.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
}
return false;
}