0

I have the following method which should retrieve all wifi networks in reach. However I get no output although there are several networks nearby.

public static void getWIFI(Context context) {
        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

        final List<ScanResult> results = wifiManager.getScanResults();

        if (results != null) {
            StringBuffer buf = new StringBuffer();

            for (int i = 0; i < results.size(); i++) {
                String ssid = results.get(i).SSID;
                buf.append(ssid + "\n");
            }

            Log.i("Test", buf.toString());
        }
}

I have added the following permissions:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

The device is a Pixel 3a, am I missing anything?

user3742929
  • 360
  • 3
  • 17

1 Answers1

-1

Mac Address

Remplace. results.get(i).SSID For results.get(i).BSSID https://developer.android.com/reference/android/net/wifi/ScanResult