title: WifiManager.addNetwork succeeds but enableNetwork fails
body: <p>I can configure and add a network (WPA2-PSK), but when I try to enable it (using WifiManager.enableNetwork), I get a failure. There's no helpful debug information in the log between the calls (other than <code>W/ActivityManager﹕ Activity idle timeout</code>). What could this be?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>        String quotedSSID = "\"" + networkSSID + "\"";
  
          WifiConfiguration conf = new WifiConfiguration();
          conf.SSID = quotedSSID;
          conf.preSharedKey = "\""+ networkPass +"\"";
          conf.hiddenSSID = true;
          conf.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
          conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
          conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
          conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
          conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
          conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  
          WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
  
          Log.w(MainActivity.APP_TAG, "Adding " + conf.SSID);
          int networkId = wifiManager.addNetwork(conf);
          if (networkId &lt; 0) {
              Log.e(MainActivity.APP_TAG, "Failed to configure " + conf.SSID);
          }
          if (!wifiManager.enableNetwork(conf.networkId, true)) {
              Log.e(MainActivity.APP_TAG, "Failed to enable " + conf.SSID);
          } else {
              Log.i(MainActivity.APP_TAG, "Enabled " + conf.SSID);
          }
  </code></pre>