title: WifiManager.getConfiguredNetworks always returns empty list
body: <p>I am trying to connect to an open wifi network. When I open my app it should turn on wifi and connect to the network defined as below. The problem is that <code>WifiManager.getConfiguredNetworks</code> always returns me an empty list. I have tried using locks too without success.</p>
  
  <pre><code>WifiConfiguration conf = new WifiConfiguration();
  conf.SSID = "\"" + networkSSID + "\"";
  conf.status = WifiConfiguration.Status.ENABLED;        
  conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
  conf.priority = Integer.MAX_VALUE;
  
  WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE); 
  wifiManager.setWifiEnabled(true);   
  wifiManager.addNetwork(conf);
  
  
  List&lt;WifiConfiguration&gt; list = wifiManager.getConfiguredNetworks();
  if(list.isEmpty()) 
  {
      Log.e("Connection Setup","Empty list returned");
  }
  
  for( WifiConfiguration i : list ) {
      if(i.SSID != null &amp;&amp; i.SSID.equals("\"" + networkSSID + "\"")) {
      Log.e("Connection Setup",i.SSID+" connrction attempted");
      wifiManager.disconnect();
      wifiManager.enableNetwork(i.networkId, true);
      wifiManager.reconnect();               
      break;
   }           
  }
  </code></pre>
  
  <p>I have been trying more things - if I make this thread sleep for about 10 seconds or so - everything works fine - but is there a better alternative?</p>