How to detect whether device has 5Ghz Wi-Fi or not

北战南征 提交于 2019-12-22 08:45:08

问题


I spent much time by seaching for solution but without result. So my question is, is there any way how to detect whether device has 5Ghz Wifi or not? It would be nice if it's possible to achieve that. I already analysed WifiManager but didn't find proper method or property.

Thanks in advance.


回答1:


As of Android API Level 21, WifiManager has a method called is5GHzBandSupported() that returns true if the adapter supports 5 GHz band.




回答2:


Our approach is to look for the results of a wifi scan and look for a signal of 5GHz. That's not a good solution, 'cause it would give false negatives, but if your context is a venue where you can assure that there are 5GHz wifis near you, it can solve the issue.

See: How can I get Android Wifi Scan Results into a list?

The data you can extract from a wifi scan (look for the frequency value):
(source: fewlaps.com)

Hope it helps!




回答3:


I resolved this using below code snip

        WifiManager wifiManager= (WifiManager) mContext.getApplicationContext().getSystemService(WIFI_SERVICE);
        Class cls = Class.forName("android.net.wifi.WifiManager");
        Method method = cls.getMethod("isDualBandSupported");

        Object invoke = method.invoke(wifiManager);
        boolean is5GhzSupported=(boolean)invoke;


来源:https://stackoverflow.com/questions/18607371/how-to-detect-whether-device-has-5ghz-wi-fi-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!