I understand that in Android you have to remove WIFI networks by network ID and not SSID.
However I am trying to remove devices that contains certain phrase in the SSID name.
Say if(k.SSID.contains("ThisWord_")) it would remove that configured network.
I can go through and display all SSID's however I dont know how to compare the SSID to the NetworkId to remove it.
Although as I said it isn't correct, I don't know how to move on honestly.
I have following codes:
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
// int networkId = wifiManager.getConnectionInfo().getNetworkId();
// wifiManager.removeNetwork(networkId);
wifiManager.saveConfiguration();
List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
List<String> ThisList = new ArrayList<String>();
int i = 0;
for(WifiConfiguration k : list)
{
if(k.SSID.contains("ThisWord_"))
{
int networkId = wifiManager.getConnectionInfo().getNetworkId();
ThisList.add(k.SSID);
i++;
wifiManager.removeNetwork(networkId);
wifiManager.saveConfiguration();
}
}
Any help is appreciated.
Just a wild guess...don't you want to remove the network id associated with the wifi configuration k?
wifiManager.removeNetwork(k.networkId)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With