Compartilhar via


WifiManager.AddNetwork(WifiConfiguration) Method

Definition

Add a new network description to the set of configured networks.

[Android.Runtime.Register("addNetwork", "(Landroid/net/wifi/WifiConfiguration;)I", "GetAddNetwork_Landroid_net_wifi_WifiConfiguration_Handler")]
public virtual int AddNetwork (Android.Net.Wifi.WifiConfiguration? config);
[<Android.Runtime.Register("addNetwork", "(Landroid/net/wifi/WifiConfiguration;)I", "GetAddNetwork_Landroid_net_wifi_WifiConfiguration_Handler")>]
abstract member AddNetwork : Android.Net.Wifi.WifiConfiguration -> int
override this.AddNetwork : Android.Net.Wifi.WifiConfiguration -> int

Parameters

config
WifiConfiguration

the set of variables that describe the configuration, contained in a WifiConfiguration object. If the WifiConfiguration has an Http Proxy set the calling app must be System, or be provisioned as the Profile or Device Owner.

Returns

the ID of the newly created network description. This is used in other operations to specified the network to be acted upon. Returns -1 on failure.

Attributes

Remarks

Add a new network description to the set of configured networks. The networkId field of the supplied configuration object is ignored.

The new network will be marked DISABLED by default. To enable it, called #enableNetwork.

This member is deprecated. a) See WifiNetworkSpecifier.Builder#build() for new mechanism to trigger connection to a Wi-Fi network. b) See #addNetworkSuggestions(List), #removeNetworkSuggestions(List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. <b>Compatibility Note:</b> For applications targeting android.os.Build.VERSION_CODES#Q or above, this API will always fail and return -1. <p> Deprecation Exemptions: <ul> <li>Device Owner (DO), Profile Owner (PO) and system apps. </ul>

Java documentation for android.net.wifi.WifiManager.addNetwork(android.net.wifi.WifiConfiguration).

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