I understand that in Android you have to remove WIFI networks by network ID, not SSID.
However, I am trying to remove devices that contain a specific phrase in the SSID.
Say that (k.SSID.contains ("ThisWord_")) this will delete this configured network.
I can go through and display all the SSIDs, but I don’t know how to compare the SSID with NetworkId to remove it.
Although, as I said, this is not correct, I do not know how to act honestly.
I have the following codes:
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
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.
source
share