I am using WifiManager to get a list of available wifi networks.
This is my method:
public List<ScanResult> getWifiInRange() {
//scan for wifis
wifiMgr.startScan();
// gets ~last~ list of WiFi networks accessible through the access point.
return (wifiScan = (List<ScanResult>) wifiMgr.getScanResults());
}
But this method doesn't retun any wifi networks on some devices!
For example, when I using this method on Asus_p024 it works correctly and returns a list of available wifi networks But on Samsung Tab-s it returns 0 items!
Update
I just changed my code and implement a broadcast like this:
public class WifiBroadcast extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
List<ScanResult> mScanResults = wifi.getScanResults();
wifiList = wifi.getScanResults();
netCount = wifiList.size();
Log.d("Wifi", "Total Wifi Network" + netCount);
}
}
I still it can't get a list of available wifi networks.
Thank you for your help.