How check if current network connected is WIFI 5G?

642 Views Asked by At

I have used this approach to check type of current connected network and works fine, except when is connected to WIFI 5G. How know if WIFI network connected is 5G? i only found how check if device supports WIFI 5G. Thanks in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

A possible solution is determine based in WIFI frequency, eg:

private static boolean is24GHzWifi(int frequency) {
        return frequency > 2400 && frequency < 2500;
    }

    private static boolean is5GHzWifi(int frequency) {
        return frequency > 4900 && frequency < 5900;
    }
    
// ...

if (info.getType() == ConnectivityManager.TYPE_WIFI) {

            WifiManager wifiMgr = (WifiManager) getContext().getSystemService(context.WIFI_SERVICE);
            WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
            int frequency = wifiInfo.getFrequency();

            if (is24GHzWifi(frequency))
                return "WIFI 2.4G";
            else if (is5GHzWifi(frequency))
                return "WIFI 5G";
            else
                return "WIFI";
  }

Reference: Android judge whether wifi is 2.4G or 5G