Getting WLAN state and subscribing to WLAN state changes

This topic describes how to get WLAN state and subscribe to WLAN state changes.

Steps

  1. Subscribe to WLANStateListener using WLANState.subscribeListener() method.

    //Sample code to subscribe to WLAN state changes
    
    try {
        WLANState.subscribeListener(this);
    }
    catch (Exception e) {
    }
  2. Implement the WLANStateListener interface by defining the WLANStateListener.WLANStateChanged() method.

    // Sample code implementing the WLANStateListener interface
    
    public void WLANStateChanged(int state) {
         form.append("WLAN state state is " + state);
    }
    
  3. Get the WLAN state by calling the WLANState.getState() method.

    //Sample code to get the WLAN state
    
    WLANState.getState();