Search code examples
androidbroadcastreceiverandroid-broadcastreceiver

android.net.wifi.STATE_CHANGE or android.net.wifi.supplicant.CONNECTION_CHANGE


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" />

Solution

  • 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