Search code examples
androidwifiwifimanager

android.net.wifi.STATE_CHANGE: not triggered on Wifi disconnect


Is it normal to only have a broadcast intent with action NETWORK_STATE_CHANGED_ACTION (whose constant value is android.net.wifi.STATE_CHANGE) when a Wifi connection is coming back up? I.e. I don't get this intent when Wifi is being disconnected.

UPDATE: I am mostly interested to >= 2.2 Froyo


Solution

  • public static final String SUPPLICANT_CONNECTION_CHANGE_ACTION

    Since: API Level 1

    Broadcast intent action indicating that a connection to the supplicant has been established (and it is now possible to perform Wi-Fi operations) or the connection to the supplicant has been lost. One extra provides the connection state as a boolean, where true means CONNECTED.

    See Also

    EXTRA_SUPPLICANT_CONNECTED

    Constant Value: "android.net.wifi.supplicant.CONNECTION_CHANGE"

    In android's API it says that it's not a good idea to check STATE_CHANGE for network connectivity and instead you should use SUPPLICANT_CONNECTION_CHANGE_ACTION. this will notice an establishment to a wifi network, and the disconnection of a wifi network. I don't know if this might help you, but I do hope so. LINK