How can I remove a saved/configured WiFi network from my Android device using WifiManager?

151 views Asked by At

Way to delete Saved/Configured WiFi networks programmatically

I added a network suggestion by the below lines of code and added the same under saved/configured networks.

 val passpointSuggestion = WifiNetworkSuggestion.Builder()
                    .setPasspointConfig(config)
                    .setIsHiddenSsid(false)
                    .setIsAppInteractionRequired(true)
                    .build()

 val networkSuggestionList = listOf(passpointSuggestion)
 wifiManager.removeNetworkSuggestions(networkSuggestionList)
 suggestionsList.add(passpointSuggestion)

I can see my added network suggestion under saved/configured networks, also I can fetch the same with the below lines of code:

 val suggestionResults = wifiManager.networkSuggestions

Now I want to remove the added saved/configured wifi from the WiFi listof thee device, I tried with:

val configuationResults = wifiManager.configuredNetworks

which always returns null on Android 11,12 and 13

Any suggestions are most appreciated.

0

There are 0 answers