I am trying to create a code that returns me available Wi-Fi networks. But I am facing a problem. getScanResults returns empty, though I have given all possible network perm
If you are using it on a device with Android 6 or higher you have to enable location services to get the scan results, even if you have the right permissions.
For more information see here: https://stackoverflow.com/a/32151901/6951450
Starting from Android 6, you have to enable location services in order to get desired results. Granting permissions is just the half work done.
You can also fire an intent to redirect user to this setting:
Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(myIntent);
Location services are necessary because when you access the scan results, you can access the information like BSSID (address of the access point). This information can also be used to detect the location of device. By requiring location services, OS ensures that user understands their location information is being accessed when they use your app.