Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not receiving updated wifi... #36

Open
DhavalRKansara opened this issue Feb 28, 2020 · 2 comments
Open

Not receiving updated wifi... #36

DhavalRKansara opened this issue Feb 28, 2020 · 2 comments

Comments

@DhavalRKansara
Copy link

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}");
      }
    });
  }
}
@DhavalRKansara
Copy link
Author

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.

@pranjal-joshi
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants