Can someone give a short explaination as to how it works in the backend? The QR code contains username and password. But how does my phone's QR scanner know that its an SSID/pw and eventually connects to the network?
Yes I saw, that is what the QR code contains (username and password of the WIFI). But I do not understand what my phone does when it sees that. There are tons of dubmbed-down articles on "how-to" instructions but none explaining the backend stuff happening on my phone's side.
The Zxing barcode scanner app does it this way: This [0] is the dispatch code. If it detects WIFI as type, it passes it to a WifiConfigManager [1] which then talks to Android's WifiManager API. On the back end, the addOrUpdateNetwork function of WifiManager [3] calls the method with the same name of IWifiManager [4]. That class has a channel to a WifiStateMachine [5] which sends a message with the command CMD_ADD_OR_UPDATE_NETWORK. It's handled in the same file (but I suppose it's in a different process, now a privileged system process), and calls the addOrUpdateNetwork function of WifiConfigStore [6].
The WifiConfigStore stores its config into a wpa_supplicant compatible file. The file is then passed to the wpa_supplicant service, which is also present on other Linux distros like the GNU/Linux ones, although here the config file is built by a dedicated NetworkManager service (also, some intel folks are building a replacement IIRC). wpa_supplicant is a privileged service that talks to the WiFi card drivers.