WifiManager.AddNetowrk on Android 9 return -1 on Galaxy S8

146 Views Asked by At

I am making Xamarin App connecting specific wifi. Above android 10, I've use AddNetworkSuggestion and works fine. This method does not work with Android 9, so when it is called on Android 9, I am calling older apis.

On Android 9, I am using AddNetwork. and some device works fine but AddNetwork return -1 on multiple Samsung Galaxy S8 Devices.

                var config = new WifiConfiguration();
                config.Ssid = '"' + ssid + '"';
                config.PreSharedKey = '"' + password + '"';
                config.AllowedAuthAlgorithms.Set((int)AuthAlgorithmType.Open);
                config.AllowedProtocols.Set((int)ProtocolType.Wpa); // For WPA
                config.AllowedProtocols.Set((int)ProtocolType.Rsn); // For WPA2
                config.AllowedKeyManagement.Set((int)KeyManagementType.WpaPsk);
                config.AllowedKeyManagement.Set((int)KeyManagementType.WpaEap);
                config.AllowedKeyManagement.Set((int)KeyManagementType.Sae);
                config.AllowedPairwiseCiphers.Set((int)PairwiseCipherType.Tkip);
                config.AllowedPairwiseCiphers.Set((int)PairwiseCipherType.Ccmp);
                config.AllowedPairwiseCiphers.Set((int)PairwiseCipherType.Gcmp256);
                config.AllowedGroupCiphers.Set((int)GroupCipherType.Tkip);
                config.AllowedGroupCiphers.Set((int)GroupCipherType.Ccmp);
                config.AllowedGroupCiphers.Set((int)GroupCipherType.Gcmp256);
                config.AllowedGroupCiphers.Set((int)GroupCipherType.Wep40);
                config.AllowedGroupCiphers.Set((int)GroupCipherType.Wep104);
                var addreturn = WifiManager.AddNetwork(config);

I am guessing Galaxy has some specific extention or customize that does not allow AddNetwork but can not figure out what is it.

Anyone have an idea to fix it?

0

There are 0 best solutions below