Search code examples
androidconfigurationandroid-wifi

Get notified when saved Wi-Fi network configuration is removed


The scenario is the following:

User has connected to a several Wifi profiles, so one can go to Wifi Settings, Saved Networks and see the list of previously connected and saved network configurations.

User has ability to remove a network from the list.

I need to perform some action upon removal of the network from the list. Ho do I intercept the removal action?

Thanks!


Solution

  • I could not find any information on profile management, the only piece of info is that when profile is changed (added/modified/removed) connection state change event occurs. Based on that info I got it working by doing the following:

    if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) {
                SupplicantState ss = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
                if (ss == SupplicantState.DISCONNECTED || ss == SupplicantState.COMPLETED) {
                    // wifi profile got removed
                }                
            } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)
                    || action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
                // bluetooth profile got removed                
            }
    

    Note, no intent is issued when inactive profile got removed.