I need to check for each network returned by the getScanResults () method if it is already configured on the device, that is, I need to check whether it exists in the list returned by getConfiguredNetworks (). The problem is this: how can I do this because the only parameter they have is the SSID? I know that this is not the best way to do this, because there may be more networks with the same SSID. As indicated in the link, networkId is the identification number that the requester uses to identify this network configuration entry, but I cannot find something similar for the ScanResult object.
So if this is my receiver:
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context c, Intent intent) { results = wifi.getScanResults(); size = results.size(); } }, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
and I get the configured networks:
List<WifiConfiguration> list = wifi.getConfiguredNetworks();
Is there a way to check if list.get (i) matches the results.get (j) configuration for any i or j?
source share