コード例 #1
0
            public string AddNetworkSuggestion()
            {
                var suggestion = new WifiNetworkSuggestion.Builder()
                                 .SetSsid(Static.Secrets.PreferredWifi)
                                 .SetWpa2Passphrase(Static.Secrets.PrefferedWifiPassword)
                                 .Build();

                var suggestions = new[] { suggestion };
                var status      = wifi.AddNetworkSuggestions(suggestions);

                if (status != NetworkStatus.SuggestionsSuccess)
                {
                    status = wifi.RemoveNetworkSuggestions(suggestions);
                    status = wifi.AddNetworkSuggestions(suggestions);
                }

                var statusText = status switch
                {
                    NetworkStatus.SuggestionsSuccess => "Pomyślnie zasugerowano sieć",
                    NetworkStatus.SuggestionsErrorAddDuplicate => "Sugestia takiej sieci już istnieje",
                    NetworkStatus.SuggestionsErrorAddExceedsMaxPerApp => "Przekroczono limit ilości sugestii"
                };

                //var toast = Toast.MakeText(Application.Context, statusText, ToastLength.Long);
                //toast.Show();

                return(statusText);
            }