wifi
wifi copied to clipboard
Not receiving updated wifi...
I am using Wifi.list('')
but it is not updating scan wifi list accurately.
Suppose There are 3 wifis are there initially and I generate one wifi with mobile hotspot and then clicking on button when I call for again Wifi.list('')
still I am getting old results with 3 wifi. Same out of 3 if I turn off any of wifi then still I get 3 wifis but If I open the default wifi setting of my phone and those wifi changes reflected over there and I requested with Wifi.list('')
then I got the updated result.
Can you please provide me suggestion that how I can get the updated wifi results without opening the default wifi setting of my Mobile phone.
- Code for getting wifi list:
_wifiList() async {
List<WifiResult> filteredList = [];
bool match = true;
Wifi.list('').then((list) {
for (WifiResult result in list) {
if (filteredList.isEmpty) {
filteredList.add(result);
} else {
for (WifiResult fResult in filteredList) {
if (result.ssid == fResult.ssid && match) {
match = false;
}
}
if (match) {
filteredList.add(result);
}
match = true;
}
}
for (WifiResult wifi in filteredList) {
print("ssid ${wifi.ssid}");
}
});
}
}
Actually there is one more library wifi_flutter In which I am getting the updated wifi list.
They implemented something like this:
IntentFilter().run {
addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)
activity.applicationContext.registerReceiver(WifiScanReceiver(result), this)
}
val wifiManager = activity.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
val scanStarted = wifiManager.startScan()
@once10301, @aryzhov and @FourLeafTec If you guys can update the same for launchWifiList
in this library then reaally it's very meaningful and useful for everyone.
I am having the same issue. The list is not getting updated. But when I open System Notification bar and check the WiFi list in the system tray, then it gets updated in the notification panel and the same results will be displayed by this library after .list('')
method called.
So I think it is causing by the Android itself which is not continuously scanning available networks, maybe for better battery life or other optimizations.
Is there any other way to Force Update the wifi list?