Search code examples
androidwifimanager

Android - What´s the difference between WifiManager disableNetwork() and disconnect()


What´s the main difference between the WifiManager disableNetwork() and disconnect() method?

If I´m not guessing wrong, the disconnect() method makes it candidate for a reconnect when it enters inside the visibility of the wifi hotspot but disableNetwork() don't.

public boolean disableNetwork (int netId). Disable a configured network. The specified network will not be a candidate for associating. This may result in the asynchronous delivery of state change events.

public boolean disconnect () Disassociate from the currently active access point. This may result in the asynchronous delivery of state change events.

I´ve a Wiko Darkmoon (Android 4.2.2) device for testing purposes and when I call disconnect() it reconnects some seconds later to the same wifi point without taking in mind higher priority networks neither the quality of the signal.

So my questions are:

  • What's the difference between disableNetwork() and disconnect() method?
  • It´s my guess right?
  • It´s the Wiko's implementation the right one or it´s the one misfiring?
  • When roaming between two wifi spots with same SSID and after calling disconnect() will it filter by SSID or MAC for the reconnect?

Thanks


Solution

  • disconnect() as name suggests just disconnects the device from current Wi-Fi network. If the device connects later to the same or another network is dependent on the device settings and is completely unrelated to the method call.

    disableNetwork(int) will prevent automatic connection to the specified network.