Reputation: 1859
In android broadcasts, what's the difference between
<action android:name="android.net.wifi.STATE_CHANGE"/>
and
<action android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" />
Upvotes: 4
Views: 5318
Reputation: 24907
<action android:name="android.net.wifi.STATE_CHANGE"/>
Broadcast intent action indicating that the state of Wi-Fi connectivity has changed.
<action android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" />
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.
Note:
This constant was deprecated in API level P. This is no longer supported.
Upvotes: 3
Reputation: 996
STATE_CHANGE : Broadcast intent action indicating that the state of Wi-Fi connectivity has changed. An extra provides the new state in the form of a NetworkInfo object.
This is lookup key for an int that indicates whether Wi-Fi is enabled, disabled, enabling, disabling, or unknown.
CONNECTION_CHANGE : 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.
This is a lookup key for a boolean that indicates whether a connection to the supplicant daemon has been gained or lost. {@code true} means a connection now exists.
P.S: SUPPLICANT_CONNECTION_CHANGE_ACTION is deprecated from API level P
Upvotes: 3
Reputation: 2027
The android.net.wifi.supplicant.CONNECTION_CHANGE action was sends a broadcast when the network is connected, but usually before the device has an IP address, so we needed the android.net.wifi.STATE_CHANGE action for that.
The android.net.wifi.STATE_CHANGE action receives a broadcast on disconnect only if the device is disconnecting from a network, but wifi is still enabled (when hotspot goes out of range, for example)
For more information see android developers officialsite https://developer.android.com/reference/android/net/wifi/WifiManager#SUPPLICANT_CONNECTION_CHANGE_ACTION
Upvotes: 0