I am trying to block wifi connections. I want my application to turn on Wi-Fi, but not connect to any network that is already stored on the smartphone. But even after I use SCAN_ONLY mode, it continues to connect to networks that already “know”.
..... wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); ..... wifiManager.setWifiEnabled(true); WifiLock scanOnly = wifiManager.createWifiLock(WifiManager.WIFI_MODE_SCAN_ONLY, "scanOnly"); scanOnly.acquire();
Already in desperation, I tried to disconnect after making sure that the status is WIFI_STATE_ENABLED wifi. That the application cannot connect for a few seconds, but after a while it connects to the network in the same ...
wifiManager.setWifiEnabled(true); .... WHEN (WIFI STATE == WIFI_STATE_ENABLED) {wifiManager.disconnect(); scanOnly.acquire();}
Can someone help me? Tks
android wifi wifimanager
Vasco Fernandes
source share