Partager via


WifiManager Class

Definition

This class provides the primary API for managing all aspects of Wi-Fi connectivity.

[Android.Runtime.Register("android/net/wifi/WifiManager", DoNotGenerateAcw=true)]
public class WifiManager : Java.Lang.Object
[<Android.Runtime.Register("android/net/wifi/WifiManager", DoNotGenerateAcw=true)>]
type WifiManager = class
    inherit Object
Inheritance
WifiManager
Attributes

Remarks

This class provides the primary API for managing all aspects of Wi-Fi connectivity.

On releases before android.os.Build.VERSION_CODES#N, this object should only be obtained from an Context#getApplicationContext() application context, and not from any other derived context to avoid memory leaks within the calling process.

It deals with several categories of items:

<ul> <li>The list of configured networks. The list can be viewed and updated, and attributes of individual entries can be modified.</li> <li>The currently active Wi-Fi network, if any. Connectivity can be established or torn down, and dynamic information about the state of the network can be queried.</li> <li>Results of access point scans, containing enough information to make decisions about what access point to connect to.</li> <li>It defines the names of various Intent actions that are broadcast upon any sort of change in Wi-Fi state. </ul>

This is the API to use when performing Wi-Fi specific operations. To perform operations that pertain to network connectivity at an abstract level, use android.net.ConnectivityManager.

Java documentation for android.net.wifi.WifiManager.

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.

Constructors

WifiManager(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

ActionPickWifiNetwork

Activity Action: Pick a Wi-Fi network to connect to.

ActionRemoveSuggestionDisconnect
Obsolete.

If one of the removed suggestions is currently connected, trigger an immediate disconnect after suggestions removal

ActionRemoveSuggestionLinger
Obsolete.

If one of the removed suggestions is currently connected, that network will be disconnected after a short delay as opposed to immediately (which will be done by #ACTION_REMOVE_SUGGESTION_DISCONNECT).

ActionRequestScanAlwaysAvailable

Activity Action: Show a system activity that allows the user to enable scans to be available even with Wi-Fi turned off.

ActionWifiNetworkSuggestionPostConnection

Directed broadcast intent action indicating that the device has connected to one of the network suggestions provided by the app.

ActionWifiScanAvailabilityChanged

Broadcast intent action indicating whether Wi-Fi scanning is currently available.

ChannelDataKeyFrequencyMhz

The bundle key string for the channel frequency in MHz.

ChannelDataKeyNumAp

The bundle key for the number of APs found on the corresponding channel specified by WifiManager#CHANNEL_DATA_KEY_FREQUENCY_MHZ.

ErrorAuthenticating

The error code if there was a problem authenticating.

ExtraBssid

The lookup key for a String giving the BSSID of the access point to which we are connected.

ExtraNetworkInfo

The lookup key for a android.net.NetworkInfo object associated with the Wi-Fi network.

ExtraNetworkSuggestion

Sent as as a part of #ACTION_WIFI_NETWORK_SUGGESTION_POST_CONNECTION that holds an instance of WifiNetworkSuggestion corresponding to the connected network.

ExtraNewRssi

The lookup key for an int giving the new RSSI in dBm.

ExtraNewState

The lookup key for a SupplicantState describing the new state Retrieve with android.content.Intent#getParcelableExtra(String).

ExtraPreviousWifiState

The previous Wi-Fi state.

ExtraResultsUpdated

Lookup key for a boolean extra in intent #SCAN_RESULTS_AVAILABLE_ACTION representing if the scan was successful or not.

ExtraScanAvailable

A boolean extra indicating whether scanning is currently available.

ExtraSupplicantConnected

The lookup key for a boolean that indicates whether a connection to the supplicant daemon has been gained or lost.

ExtraSupplicantError

The lookup key for a SupplicantState describing the supplicant error code if any Retrieve with android.content.Intent#getIntExtra(String, int).

ExtraWifiInfo

The lookup key for a android.net.wifi.WifiInfo object giving the information about the access point to which we are connected.

ExtraWifiState

The lookup key for an int that indicates whether Wi-Fi is enabled, disabled, enabling, disabling, or unknown.

FlagSendDhcpHostnameRestrictionOpen
Obsolete.

Do not send the DHCP hostname to open networks.

FlagSendDhcpHostnameRestrictionSecure
Obsolete.

Do not send the DHCP hostname to secure network.

NetworkIdsChangedAction

The network IDs of the configured networks could have changed.

NetworkStateChangedAction

Broadcast intent action indicating that the state of Wi-Fi connectivity has changed.

RoamingModeAggressive
Obsolete.

Allows the device to roam more quickly than the normal roaming mode.

RoamingModeNone
Obsolete.

Roaming is disabled.

RoamingModeNormal
Obsolete.

Chipset has roaming trigger capability based on the score calculated using multiple parameters.

RssiChangedAction

The RSSI (signal strength) has changed.

ScanResultsAvailableAction

An access point scan has completed, and results are available.

StatusLocalOnlyConnectionFailureAssociation
Obsolete.

Reason code if local-only network connection attempt failed with association failure.

StatusLocalOnlyConnectionFailureAuthentication
Obsolete.

Reason code if local-only network connection attempt failed with an authentication failure.

StatusLocalOnlyConnectionFailureIpProvisioning
Obsolete.

Reason code if local-only network connection attempt failed with an IP provisioning failure.

StatusLocalOnlyConnectionFailureNoResponse
Obsolete.

Reason code if local-only network connection attempt failed with AP not responding

StatusLocalOnlyConnectionFailureNotFound
Obsolete.

Reason code if local-only network connection attempt failed with AP not in range.

StatusLocalOnlyConnectionFailureUnknown
Obsolete.

Reason code if local-only network connection attempt failed with an unknown failure.

StatusNetworkSuggestionsErrorAddDuplicate
Obsolete.

Reason code if one or more of the network suggestions added already exists in platform's database.

StatusNetworkSuggestionsErrorAddExceedsMaxPerApp
Obsolete.

Reason code if the number of network suggestions provided by the app crosses the max threshold set per app.

StatusNetworkSuggestionsErrorAddInvalid
Obsolete.

Reason code if one or more of the network suggestions added is invalid.

StatusNetworkSuggestionsErrorAddNotAllowed
Obsolete.

Reason code if one or more of the network suggestions added is not allowed.

StatusNetworkSuggestionsErrorAppDisallowed
Obsolete.

Reason code if the user has disallowed "android:change_wifi_state" app-ops from the app.

StatusNetworkSuggestionsErrorInternal
Obsolete.

Reason code if there was an internal error in the platform while processing the addition or removal of suggestions.

StatusNetworkSuggestionsErrorRemoveInvalid
Obsolete.

Reason code if one or more of the network suggestions removed does not exist in platform's database.

StatusNetworkSuggestionsErrorRestrictedByAdmin
Obsolete.

Reason code if android.os.UserManager#DISALLOW_ADD_WIFI_CONFIG user restriction is set and calling app is restricted by device admin.

StatusNetworkSuggestionsSuccess
Obsolete.

Reason code if all of the network suggestions were successfully added or removed.

StatusSuggestionApprovalApprovedByCarrierPrivilege
Obsolete.

Status code if the calling app was approved by virtue of being a carrier privileged app.

StatusSuggestionApprovalApprovedByUser
Obsolete.

Status code if the calling app got the user approval for suggestions.

StatusSuggestionApprovalPending
Obsolete.

Status code if the calling app is still pending user approval for suggestions.

StatusSuggestionApprovalRejectedByUser
Obsolete.

Status code if the calling app suggestions were rejected by the user.

StatusSuggestionApprovalUnknown
Obsolete.

Status code if suggestion approval status is unknown, an App which hasn't made any suggestions will get this code.

StatusSuggestionConnectionFailureAssociation
Obsolete.

Reason code if suggested network connection attempt failed with association failure.

StatusSuggestionConnectionFailureAuthentication
Obsolete.

Reason code if suggested network connection attempt failed with an authentication failure.

StatusSuggestionConnectionFailureIpProvisioning
Obsolete.

Reason code if suggested network connection attempt failed with an IP provision failure.

StatusSuggestionConnectionFailureUnknown
Obsolete.

Reason code if suggested network connection attempt failed with an unknown failure.

SupplicantConnectionChangeAction

Broadcast intent action indicating that a connection to the supplicant has been established (and it is now possible to perform Wi-Fi operations) or the connection to the supplicant has been lost.

SupplicantStateChangedAction

Broadcast intent action indicating that the state of establishing a connection to an access point has changed.

UnknownSsid

Indicates an invalid SSID.

WifiInterfaceTypeAp
Obsolete.

Wi-Fi interface of type AP (access point Wi-Fi infrastructure device).

WifiInterfaceTypeAware
Obsolete.

Wi-Fi interface of type Wi-Fi Aware (aka NAN).

WifiInterfaceTypeDirect
Obsolete.

Wi-Fi interface of type Wi-Fi Direct (aka P2P).

WifiInterfaceTypeSta
Obsolete.

Wi-Fi interface of type STA (station/client Wi-Fi infrastructure device).

WifiMultiInternetModeDbsAp
Obsolete.

Wi-Fi simultaneous connection to multiple internet-providing Wi-FI networks (APs) is enabled and restricted to a single network on different bands (e.

WifiMultiInternetModeDisabled
Obsolete.

Wi-Fi simultaneous connection to multiple internet-providing Wi-Fi networks (APs) is disabled.

WifiMultiInternetModeMultiAp
Obsolete.

Wi-Fi simultaneous connection to multiple internet-providing Wi-Fi networks (APs) is enabled.

WifiStateChangedAction

Broadcast intent action indicating that Wi-Fi has been enabled, disabled, enabling, disabling, or unknown.

Properties

CallerConfiguredNetworks

Return a list of all the networks previously configured by the calling app.

Class

Returns the runtime class of this Object.

(Inherited from Object)
ConfiguredNetworks

Return a list of all the networks configured for the current foreground user.

ConnectionInfo

Return dynamic information about the current Wi-Fi connection, if any is active.

DhcpInfo

Return the DHCP-assigned addresses from the last successful DHCP request, if any.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsAggressiveRoamingModeSupported
IsAutoWakeupEnabled

Get the persisted Wi-Fi auto wakeup feature state.

IsBridgedApConcurrencySupported

Query whether or not the device supports multiple Access point (AP) which are bridged together.

IsD2dSupportedWhenInfraStaDisabled
IsDecoratedIdentitySupported
IsDeviceToApRttSupported

This member is deprecated.

IsDualBandSimultaneousSupported
IsEasyConnectDppAkmSupported

Wi-Fi Easy Connect DPP AKM enables provisioning and configuration of Wi-Fi devices without the need of using the device PSK passphrase.

IsEasyConnectEnrolleeResponderModeSupported
IsEasyConnectSupported

Wi-Fi Easy Connect (DPP) introduces standardized mechanisms to simplify the provisioning and configuration of Wi-Fi devices.

IsEnhancedOpenSupported
IsEnhancedPowerReportingSupported
IsMakeBeforeBreakWifiSwitchingSupported

Query whether or not the device supports concurrent station (STA) connections for make-before-break wifi to wifi switching.

IsP2pSupported
IsPasspointTermsAndConditionsSupported
IsPreferredNetworkOffloadSupported
IsScanAlwaysAvailable

Check if scanning is always available.

IsScanThrottleEnabled

Get the persisted Wi-Fi scan throttle state.

IsStaApConcurrencySupported

Query whether or not the device supports Station (STA) + Access point (AP) concurrency.

IsStaBridgedApConcurrencySupported

Query whether or not the device supports concurrency of Station (STA) + multiple access points (AP) (where the APs bridged together).

IsStaConcurrencyForLocalOnlyConnectionsSupported

Query whether or not the device supports concurrent station (STA) connections for local-only connections using WifiNetworkSpecifier.

IsStaConcurrencyForMultiInternetSupported

Query whether or not the device supports concurrent station (STA) connections for multi internet connections.

IsTdlsSupported
IsTidToLinkMappingNegotiationSupported
IsTlsMinimumVersionSupported

Indicate that whether or not settings required TLS minimum version is supported.

IsTlsV13Supported

Indicate that whether or not TLS v1.

IsTrustOnFirstUseSupported
IsWapiSupported
IsWepSupported
IsWifiDisplayR2Supported
IsWifiEnabled

Return whether Wi-Fi is enabled or disabled.

IsWifiPasspointEnabled

If the device supports Wi-Fi Passpoint, the user can explicitly enable or disable it.

IsWpa3SaeH2eSupported
IsWpa3SaePublicKeySupported
IsWpa3SaeSupported
IsWpa3SuiteBSupported
IsWpaPersonalSupported
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
MaxNumberOfChannelsPerNetworkSpecifierRequest

Returns the max number of channels that is allowed to be set on a WifiNetworkSpecifier.

MaxNumberOfNetworkSuggestionsPerApp

Returns the max number of network suggestions that are allowed per app on the device.

MaxSignalLevel

Get the system default maximum signal level.

NetworkSuggestions

Get all network suggestions provided by the calling app.

PasspointConfigurations

Return the list of installed Passpoint configurations added by the caller.

PeerReference (Inherited from Object)
ScanResults

Return the results of the latest access point scan.

StaConcurrencyForMultiInternetMode

The device may support concurrent connections to multiple internet-providing Wi-Fi networks (APs) - that is indicated by WifiManager#isStaConcurrencyForMultiInternetSupported().

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

WifiState

Gets the Wi-Fi enabled state.

Methods

AddLocalOnlyConnectionFailureListener(IExecutor, WifiManager+ILocalOnlyConnectionFailureListener)
AddNetwork(WifiConfiguration)

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

AddNetworkPrivileged(WifiConfiguration)
AddNetworkSuggestions(IList<WifiNetworkSuggestion>)

Provide a list of network suggestions to the device.

AddOrUpdatePasspointConfiguration(PasspointConfiguration)

Add or update a Passpoint configuration.

AddSuggestionConnectionStatusListener(IExecutor, WifiManager+ISuggestionConnectionStatusListener)
AddSuggestionUserApprovalStatusListener(IExecutor, WifiManager+ISuggestionUserApprovalStatusListener)
AllowAutojoinGlobal(Boolean)

Control whether the device will automatically search for and connect to Wi-Fi networks - auto-join Wi-Fi networks.

CalculateSignalLevel(Int32, Int32)

Calculates the level of the signal.

CalculateSignalLevel(Int32)

Given a raw RSSI, return the RSSI signal quality rating using the system default RSSI quality rating thresholds.

CancelWps(WifiManager+WpsCallback)

Cancel any ongoing Wi-fi Protected Setup

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CompareSignalLevel(Int32, Int32)

Compares two signal strengths.

CreateMulticastLock(String)

Create a new MulticastLock

CreateWifiLock(String)

Creates a new WifiLock.

CreateWifiLock(WifiMode, String)

Creates a new WifiLock.

DisableNetwork(Int32)

Disable a configured network.

Disconnect()

Disassociate from the currently active access point.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
EnableNetwork(Int32, Boolean)

Allow a previously configured network to be associated with.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FlushPasspointAnqpCache()

Flush Passpoint ANQP cache, and clear pending ANQP requests.

FromContext(Context)
GetAllowedChannels(WifiBand, WifiAvailableChannelModes)

Returns a list of WifiAvailableChannel for the specified band and operational mode(s), that is allowed for the current regulatory domain.

GetChannelData(IExecutor, IConsumer)

Get channel data such as the number of APs found on each channel from the most recent scan.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetMaxSupportedConcurrentTdlsSessions(IExecutor, IConsumer)

Return the maximum number of concurrent TDLS sessions supported by the device.

GetNumberOfEnabledTdlsSessions(IExecutor, IConsumer)

Return the number of currently enabled TDLS sessions.

GetPerSsidRoamingModes(IExecutor, IConsumer)

This API allows a privileged application to get roaming mode policies configured using the #setPerSsidRoamingMode(WifiSsid, int).

GetUsableChannels(WifiBand, WifiAvailableChannelModes)

Returns a list of WifiAvailableChannel for the specified band and operational mode(s) per the current regulatory domain and device-specific constraints such as concurrency state and interference due to other radios.

Is24GHzBandSupported()

Check if the chipset supports 2.

Is5GHzBandSupported()

Check if the chipset supports 5GHz band.

Is60GHzBandSupported()

Check if the chipset supports the 60GHz frequency band.

Is6GHzBandSupported()

Check if the chipset supports 6GHz band.

IsCarrierNetworkOffloadEnabled(Int32, Boolean)

Get the carrier network offload state for merged or unmerged networks for specified subscription.

IsTdlsOperationCurrentlyAvailable(IExecutor, IConsumer)

Check if a TDLS session can be established at this time via #setTdlsEnabled(InetAddress, boolean) or #setTdlsEnabledWithMacAddress(String, boolean) or #setTdlsEnabled(InetAddress, boolean, Executor, Consumer) or #setTdlsEnabledWithMacAddress(String, boolean, Executor, Consumer)

        Internally framework checks the STA connected state, device support for TDLS and
        the number of TDLS sessions available in driver/firmware.
IsWifiStandardSupported(Int32)

Check if the chipset supports a certain Wi-Fi standard.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
PingSupplicant()

Check that the supplicant daemon is responding to requests.

QueryAutojoinGlobal(IExecutor, IConsumer)

Query whether or not auto-join global is enabled/disabled

QuerySendDhcpHostnameRestriction(IExecutor, IIntConsumer)

Query the global restriction on which networks to send the device hostname to during DHCP.

Reassociate()

Reconnect to the currently active access point, even if we are already connected.

Reconnect()

Reconnect to the currently active access point, if we are currently disconnected.

RegisterScanResultsCallback(IExecutor, WifiManager+ScanResultsCallback)
RegisterSubsystemRestartTrackingCallback(IExecutor, WifiManager+SubsystemRestartTrackingCallback)
RemoveLocalOnlyConnectionFailureListener(WifiManager+ILocalOnlyConnectionFailureListener)
RemoveNetwork(Int32)

Remove the specified network from the list of configured networks.

RemoveNetworkSuggestions(IList<WifiNetworkSuggestion>, Int32)

Remove some or all of the network suggestions that were previously provided by the app.

RemoveNetworkSuggestions(IList<WifiNetworkSuggestion>)

Remove some or all of the network suggestions that were previously provided by the app.

RemoveNonCallerConfiguredNetworks()

Remove all configured networks that were not created by the calling app.

RemovePasspointConfiguration(String)

Remove the Passpoint configuration identified by its FQDN (Fully Qualified Domain Name) added by the caller.

RemovePerSsidRoamingMode(WifiSsid)

This API allows a privileged application to remove roaming mode policy configured using the #setPerSsidRoamingMode(WifiSsid, int).

RemoveSuggestionConnectionStatusListener(WifiManager+ISuggestionConnectionStatusListener)
RemoveSuggestionUserApprovalStatusListener(WifiManager+ISuggestionUserApprovalStatusListener)
ReportCreateInterfaceImpact(Int32, Boolean, IExecutor, IBiConsumer)

Queries the framework to determine whether the specified interface can be created, and if so - what other interfaces would be torn down by the framework to allow this creation if it were requested.

SaveConfiguration()

Tell the device to persist the current list of configured networks.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetPerSsidRoamingMode(WifiSsid, Int32)

This API allows a privileged application to set roaming mode per SSID.

SetSendDhcpHostnameRestriction(SendDhcpHostnameRestriction)

Sets the global restrictions on which networks to send the device hostname to during DHCP.

SetTdlsEnabled(InetAddress, Boolean, IExecutor, IConsumer)

Enable/Disable TDLS on a specific local route.

SetTdlsEnabled(InetAddress, Boolean)

Enable/Disable TDLS on a specific local route.

SetTdlsEnabledWithMacAddress(String, Boolean, IExecutor, IConsumer)

Enable/Disable TDLS with a specific peer Mac Address.

SetTdlsEnabledWithMacAddress(String, Boolean)

Similar to #setTdlsEnabled(InetAddress, boolean) , except this version allows you to specify remote endpoint with a MAC address.

SetWifiEnabled(Boolean)

Enable or disable Wi-Fi.

StartLocalOnlyHotspot(WifiManager+LocalOnlyHotspotCallback, Handler)
StartScan()

Request a scan for access points.

StartWps(WpsInfo, WifiManager+WpsCallback)

Start Wi-fi Protected Setup

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
UnregisterScanResultsCallback(WifiManager+ScanResultsCallback)
UnregisterSubsystemRestartTrackingCallback(WifiManager+SubsystemRestartTrackingCallback)
UpdateNetwork(WifiConfiguration)

Update the network description of an existing configured network.

ValidateSoftApConfiguration(SoftApConfiguration)

Check if input configuration is valid.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to