title: Application (WiFi connections) doesn't work anymore on Android 6.0 Marshmallow
body: <p>My application stopped working once I upgraded to Marshmallow, it was supposed to be able to change the WiFi connection, but now it doesn't do anything at all.</p>
  
  <p>I've spent some time reading about the new permission model of the Android 6.0. Well awesome, but old apps should continue working... Anyway, I started trying to implement the granting of permission, but realized that this is a normal permission and there should be done no permission request for it if it's defined in android manifest:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt;
  </code></pre>
  
  <p>The permission has always been in Android Manifest, and if I understand correctly it is supposed to work because it's a "Normal permission". So why doesn't it work, does anybody have a solution?</p>
  
  <p>Adding the code fragment related to my case:</p>
  
  <pre><code>protected void connectWifi() {
      if ((!connectedToAccessPoint(settings.getMainConnectionName()))
              &amp;&amp; (accessPointIsAvailable(settings.getMainConnectionName()))) {
          ConnectionUtils.connectToWifi(this,
                  settings.getMainConnectionName(),
                  settings.getMainConnectionPassword());
          Toast.makeText(this,
                  "Connecting to " + settings.getMainConnectionName(),
                  Toast.LENGTH_LONG).show();
          handler.postDelayed(sendUpdatesToUI,
                  DelayConstants.BASIC_REQUEST_SENT);
          handler.postDelayed(sendUpdatesToUI,
                  DelayConstants.CHANGE_CONNECTION);
      }
  }
  </code></pre>
  
  <p>And here the technical part for the connection:</p>
  
  <pre><code>public static void connectToWifi(Context context, String ssid, String password) {
       WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
       // setup a wifi configuration
        WifiConfiguration wc = new WifiConfiguration();
        wc.SSID = "\"" + ssid + "\"";
        wc.preSharedKey = "\""+ password + "\"";
        wc.status = WifiConfiguration.Status.ENABLED;
        wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
        wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
        wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
      // connect to and enable the connection
       int netId = wifiManager.addNetwork(wc);
       wifiManager.enableNetwork(netId, true);
       wifiManager.setWifiEnabled(true);
  }
  </code></pre>
  
  <p>In AndroidManifest as mentioned before there's that CHANGE_WIFI_STATE permission, which was there since the app was running on devices not having Android 6.0</p>