Android Wifi Scan - BroadcastReceiver for SCAN_RESULTS_AVAILABLE_ACTION not getting called
<p>Here is my code:</p>

<pre><code>public class FloatWifiManager implements IWifiManager {

    private WifiManager wifiManager;

    private BroadcastReceiver wifiScanReceiver;

    public FloatWifiManager(Context context) {
        ...
        wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

        // Registering Wifi Receiver
        wifiScanReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context c, Intent intent) {
                if (intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
                    // not getting called, only after running app and manually going to the wifi settings in android
                }
            }
        };

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
        context.registerReceiver(wifiScanReceiver, intentFilter);
        wifiManager.startScan();
    }
</code></pre>

<p>I registered the <code>BroadcastReceiver</code> exactly like I saw in all the examples, and did <code>startScan</code>.</p>

<p>What happens is, the <strong>wifi list</strong> is changing (for sure, I tested), but <code>onReceive</code> is not called if I just stay in the app.</p>

<p>What makes <code>onReceive</code> finally to be called - is to launch the app, leave it running, and going in the android phone to <strong>Settings</strong> -> <strong>Wifi settings</strong>. when going there, all of the sudden the List is updating and <code>onReceive</code> is called.</p>

<p>What's the problem here?</p>

<ol>
<li><p>Does  <code>wifiManager.startScan();</code> runs the scan only once? or it is a function that keeps listening to incoming "Scan Results"?</p></li>
<li><p>And obviously, why does the receiver doesn't get called?</p></li>
</ol>