title: Wifi Scanner doesn't work with android nougat (7.0)
body: <p>I want to scan all wifi when the wifi is turning on but it doesn't work with android 7.0 and I have only this phone for test (I think it's a android version problem). </p>
  
  <p>How can I fix my problem?</p>
  
  <p>Code : </p>
  
  <pre><code>import android.app.Activity;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent; 
  import android.content.IntentFilter;
  import android.net.wifi.ScanResult;
  import android.net.wifi.WifiManager;
  import android.os.Bundle; 
  import android.view.View;
  import android.widget.Button;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  
  
  
  public class DetectWifi extends Activity implements View.OnClickListener
  {
    WifiManager wifi;
    ListView lv;
    TextView textStatus;
    Button buttonScan;
    int size = 0;
    List&lt;ScanResult&gt; results;
  
    String ITEM_KEY = "key";
    ArrayList&lt;HashMap&lt;String, String&gt;&gt; arraylist = new   ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
    SimpleAdapter adapter;
  
    /* Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.detectwifi_page);
  
      textStatus = (TextView) findViewById(R.id.textStatus);
      buttonScan = (Button) findViewById(R.id.buttonScan);
      buttonScan.setOnClickListener(this);
      lv = (ListView)findViewById(R.id.list);
  
      wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
      if (wifi.isWifiEnabled() == false)
      {
          Toast.makeText(getApplicationContext(), "wifi is disabled..making it enabled", Toast.LENGTH_LONG).show();
          wifi.setWifiEnabled(true);
      }
      this.adapter = new SimpleAdapter(DetectWifi.this, arraylist, R.layout.dialog_wifi, new String[] { ITEM_KEY }, new int[] { R.id.list_value });
      lv.setAdapter(this.adapter);
  
      registerReceiver(new BroadcastReceiver()
      {
          @Override
          public void onReceive(Context c, Intent intent)
          {
              results = wifi.getScanResults();
              size = results.size();
          }
      }, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
  }
  
  public void onClick(View view)
  {
      arraylist.clear();
      wifi.startScan();
  
      Toast.makeText(this, "Scanning...." + size, Toast.LENGTH_SHORT).show();
      try
      {
          size = size - 1;
          while (size &gt;= 0)
          {
              HashMap&lt;String, String&gt; item = new HashMap&lt;String, String&gt;();
              item.put(ITEM_KEY, results.get(size).SSID + "  " + results.get(size).capabilities);
  
              arraylist.add(item);
              size--;
              adapter.notifyDataSetChanged();
          }
      }
      catch (Exception e)
      { }
   }
  }
  </code></pre>
  
  <p>Thanks a lot.</p>