I am trying to check wireless networks and find this useful source on the network. Unfortunately, it does not work, and I have no idea why. My problem is that I can’t wait 10 minutes for the result - I need them for a few seconds and thought about setting a boolean variable that expects false as soon as I get the result ... well, it works forever. .nothing seems to be received. Any ideas? Thank.
IntentFilter i = new IntentFilter();
i.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context c, Intent i){
mWifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);
wireless = mWifiManager.getScanResults();
waiting = false;
}
}
,i);
mWifiManager.startScan();
while (waiting) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.d("PROJECT1","Wifi WAITING");
}
source
share