共用方式為


Settings.ExtraWifiNetworkList Field

Definition

A bundle extra of #ACTION_WIFI_ADD_NETWORKS intent action that indicates the list of the android.net.wifi.WifiNetworkSuggestion elements.

[Android.Runtime.Register("EXTRA_WIFI_NETWORK_LIST", ApiSince=30)]
public const string ExtraWifiNetworkList;
[<Android.Runtime.Register("EXTRA_WIFI_NETWORK_LIST", ApiSince=30)>]
val mutable ExtraWifiNetworkList : string

Field Value

Attributes

Remarks

A bundle extra of #ACTION_WIFI_ADD_NETWORKS intent action that indicates the list of the android.net.wifi.WifiNetworkSuggestion elements. The maximum count of the android.net.wifi.WifiNetworkSuggestion elements in the list will be five.

For example: To provide credentials for one open and one WPA2 networks:

{@code
            final WifiNetworkSuggestion suggestion1 =
                  new WifiNetworkSuggestion.Builder()
                  .setSsid("test111111")
                  .build();
            final WifiNetworkSuggestion suggestion2 =
                  new WifiNetworkSuggestion.Builder()
                  .setSsid("test222222")
                  .setWpa2Passphrase("test123456")
                  .build();
            final List<WifiNetworkSuggestion> suggestionsList = new ArrayList<>;
            suggestionsList.add(suggestion1);
            suggestionsList.add(suggestion2);
            Bundle bundle = new Bundle();
            bundle.putParcelableArrayList(Settings.EXTRA_WIFI_NETWORK_LIST,(ArrayList<? extends
            Parcelable>) suggestionsList);
            final Intent intent = new Intent(Settings.ACTION_WIFI_ADD_NETWORKS);
            intent.putExtras(bundle);
            startActivityForResult(intent, 0);
            }

Java documentation for android.provider.Settings.EXTRA_WIFI_NETWORK_LIST.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to