I need to check for every network returned by getScanResults() method if it is already configured in the device, that is, I need to check if it exist in the list returned by getConfiguredNetworks(). The problem is: how can I do this since the only parameter they have in common is SSID? I know this wouldn't be the good way to do it because there could be more networks with same SSID. As stated in the reference, networkId is The ID number that the supplicant uses to identify this network configuration entry, but I can't 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 this is how i get the configured networks:
List<WifiConfiguration> list = wifi.getConfiguredNetworks();
Is there a way to check if list.get(i) corresponds to results.get(j) configuration, for whatever i or j?
You can check if the BSSIDs of both the networks match. ScanResult and WifiConfiguration both supply a BSSID, which is unique to a network.
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