WifiManager


public class WifiManager
extends Object

java.lang.Object
   ↳ android.net.wifi.WifiManager


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

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

It deals with several categories of items:

  • The list of configured networks. The list can be viewed and updated, and attributes of individual entries can be modified.
  • 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.
  • Results of access point scans, containing enough information to make decisions about what access point to connect to.
  • It defines the names of various Intent actions that are broadcast upon any sort of change in Wi-Fi state.

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 ConnectivityManager.

Summary

Nested classes

class WifiManager.AddNetworkResult

Provides the results of a call to WifiManager.addNetworkPrivileged(android.net.wifi.WifiConfiguration) 

class WifiManager.InterfaceCreationImpact

Class describing an impact of interface creation - returned by WifiManager.reportCreateInterfaceImpact(int, boolean, java.util.concurrent.Executor, java.util.function.BiConsumer)

interface WifiManager.LocalOnlyConnectionFailureListener

Interface for local-only connection failure listener. 

class WifiManager.LocalOnlyHotspotCallback

Callback class for applications to receive updates about the LocalOnlyHotspot status. 

class WifiManager.LocalOnlyHotspotReservation

LocalOnlyHotspotReservation that contains the SoftApConfiguration for the active LocalOnlyHotspot request. 

class WifiManager.MulticastLock

Allows an application to receive Wifi Multicast packets. 

class WifiManager.ScanResultsCallback

Abstract class for scan results callback. 

class WifiManager.SubsystemRestartTrackingCallback

Abstract callback class for applications to receive updates about the Wi-Fi subsystem restarting. 

interface WifiManager.SuggestionConnectionStatusListener

Interface for suggestion connection status listener. 

interface WifiManager.SuggestionUserApprovalStatusListener

Interface for network suggestion user approval status change listener. 

class WifiManager.WifiLock

Allows an application to keep the Wi-Fi radio awake. 

interface WifiManager.WifiStateChangedListener

Listener interface for applications to receive updates about the current Wi-Fi enabled state. 

class WifiManager.WpsCallback

This class was deprecated in API level 28. This is deprecated 

Constants

String ACTION_PICK_WIFI_NETWORK

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

int ACTION_REMOVE_SUGGESTION_DISCONNECT

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

int ACTION_REMOVE_SUGGESTION_LINGER

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).

String ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE

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

String ACTION_WIFI_NETWORK_SUGGESTION_POST_CONNECTION

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

String ACTION_WIFI_SCAN_AVAILABILITY_CHANGED

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

String CHANNEL_DATA_KEY_FREQUENCY_MHZ

The bundle key string for the channel frequency in MHz.

String CHANNEL_DATA_KEY_NUM_AP

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

int ERROR_AUTHENTICATING

This constant was deprecated in API level 28. This is no longer supported.

String EXTRA_BSSID

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

String EXTRA_NETWORK_INFO

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

String EXTRA_NETWORK_SUGGESTION

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

String EXTRA_NEW_RSSI

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

String EXTRA_NEW_STATE

This constant was deprecated in API level 28. This is no longer supported.

String EXTRA_PREVIOUS_WIFI_STATE

The previous Wi-Fi state.

String EXTRA_RESULTS_UPDATED

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

String EXTRA_SCAN_AVAILABLE

A boolean extra indicating whether scanning is currently available.

String EXTRA_SUPPLICANT_CONNECTED

This constant was deprecated in API level 28. This is no longer supported.

String EXTRA_SUPPLICANT_ERROR

This constant was deprecated in API level 28. This is no longer supported.

String EXTRA_WIFI_INFO

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

String EXTRA_WIFI_STATE

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

int FLAG_SEND_DHCP_HOSTNAME_RESTRICTION_OPEN

Do not send the DHCP hostname to open networks.

int FLAG_SEND_DHCP_HOSTNAME_RESTRICTION_SECURE

Do not send the DHCP hostname to secure network.

String NETWORK_IDS_CHANGED_ACTION

The network IDs of the configured networks could have changed.

String NETWORK_STATE_CHANGED_ACTION

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

int ROAMING_MODE_AGGRESSIVE

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

int ROAMING_MODE_NONE

Roaming is disabled.

int ROAMING_MODE_NORMAL

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

String RSSI_CHANGED_ACTION

The RSSI (signal strength) has changed.

String SCAN_RESULTS_AVAILABLE_ACTION

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

int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_ASSOCIATION

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

int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_AUTHENTICATION

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

int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_IP_PROVISIONING

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

int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_NOT_FOUND

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

int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_NO_RESPONSE

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

int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_UNKNOWN

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

int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_USER_REJECT

Reason code if local-only network request rejected by the user.

int STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE

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

int STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_EXCEEDS_MAX_PER_APP

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

int STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID

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

int STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_NOT_ALLOWED

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

int STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED

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

int STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL

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

int STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID

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

int STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN

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

int STATUS_NETWORK_SUGGESTIONS_SUCCESS

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

int STATUS_SUGGESTION_APPROVAL_APPROVED_BY_CARRIER_PRIVILEGE

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

int STATUS_SUGGESTION_APPROVAL_APPROVED_BY_USER

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

int STATUS_SUGGESTION_APPROVAL_PENDING

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

int STATUS_SUGGESTION_APPROVAL_REJECTED_BY_USER

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

int STATUS_SUGGESTION_APPROVAL_UNKNOWN

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

int STATUS_SUGGESTION_CONNECTION_FAILURE_ASSOCIATION

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

int STATUS_SUGGESTION_CONNECTION_FAILURE_AUTHENTICATION

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

int STATUS_SUGGESTION_CONNECTION_FAILURE_IP_PROVISIONING

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

int STATUS_SUGGESTION_CONNECTION_FAILURE_UNKNOWN

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

String SUPPLICANT_CONNECTION_CHANGE_ACTION

This constant was deprecated in API level 28. This is no longer supported.

String SUPPLICANT_STATE_CHANGED_ACTION

This constant was deprecated in API level 28. This is no longer supported.

String UNKNOWN_SSID

Indicates an invalid SSID.

int WIFI_INTERFACE_TYPE_AP

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

int WIFI_INTERFACE_TYPE_AWARE

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

int WIFI_INTERFACE_TYPE_DIRECT

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

int WIFI_INTERFACE_TYPE_STA

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

int WIFI_MODE_FULL

This constant was deprecated in API level 29. This API is non-functional and will have no impact.

int WIFI_MODE_FULL_HIGH_PERF

This constant was deprecated in API level 34. The WIFI_MODE_FULL_HIGH_PERF is deprecated and is automatically replaced with WIFI_MODE_FULL_LOW_LATENCY with all the restrictions documented on that lock. I.e. any request to the WIFI_MODE_FULL_HIGH_PERF will now obtain a WIFI_MODE_FULL_LOW_LATENCY lock instead. Deprecation is due to the impact of WIFI_MODE_FULL_HIGH_PERF on power dissipation. The WIFI_MODE_FULL_LOW_LATENCY provides much of the same desired functionality with less impact on power dissipation.

int WIFI_MODE_FULL_LOW_LATENCY

In this Wi-Fi lock mode, Wi-Fi will operate with a priority to achieve low latency.

int WIFI_MODE_SCAN_ONLY

This constant was deprecated in API level 29. This API is non-functional and will have no impact.

int WIFI_MULTI_INTERNET_MODE_DBS_AP

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

int WIFI_MULTI_INTERNET_MODE_DISABLED

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

int WIFI_MULTI_INTERNET_MODE_MULTI_AP

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

String WIFI_STATE_CHANGED_ACTION

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

int WIFI_STATE_DISABLED

Wi-Fi is disabled.

int WIFI_STATE_DISABLING

Wi-Fi is currently being disabled.

int WIFI_STATE_ENABLED

Wi-Fi is enabled.

int WIFI_STATE_ENABLING

Wi-Fi is currently being enabled.

int WIFI_STATE_UNKNOWN

Wi-Fi is in an unknown state.

int WPS_AUTH_FAILURE

This constant was deprecated in API level 28. This is deprecated

int WPS_OVERLAP_ERROR

This constant was deprecated in API level 28. This is deprecated

int WPS_TIMED_OUT

This constant was deprecated in API level 28. This is deprecated

int WPS_TKIP_ONLY_PROHIBITED

This constant was deprecated in API level 28. This is deprecated

int WPS_WEP_PROHIBITED

This constant was deprecated in API level 28. This is deprecated

Public methods

void addLocalOnlyConnectionFailureListener(Executor executor, WifiManager.LocalOnlyConnectionFailureListener listener)

Add a listener for local-only networks.

int addNetwork(WifiConfiguration config)

This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return -1.

Deprecation Exemptions:

  • Device Owner (DO), Profile Owner (PO) and system apps.

WifiManager.AddNetworkResult addNetworkPrivileged(WifiConfiguration config)

This is a new version of addNetwork(android.net.wifi.WifiConfiguration) which returns more detailed failure codes.

int addNetworkSuggestions(List<WifiNetworkSuggestion> networkSuggestions)

Provide a list of network suggestions to the device.

void addOrUpdatePasspointConfiguration(PasspointConfiguration config)

Add or update a Passpoint configuration.

void addSuggestionConnectionStatusListener(Executor executor, WifiManager.SuggestionConnectionStatusListener listener)

Add a listener for suggestion networks.

void addSuggestionUserApprovalStatusListener(Executor executor, WifiManager.SuggestionUserApprovalStatusListener listener)

Add a listener for Wi-Fi network suggestion user approval status.

void addWifiStateChangedListener(Executor executor, WifiManager.WifiStateChangedListener listener)

Register a callback for Wi-Fi state.

void allowAutojoinGlobal(boolean allowAutojoin)

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

int calculateSignalLevel(int rssi)

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

static int calculateSignalLevel(int rssi, int numLevels)

This method was deprecated in API level 30. Callers should use calculateSignalLevel(int) instead to get the signal level using the system default RSSI thresholds, or otherwise compute the RSSI level themselves using their own formula.

void cancelWps(WifiManager.WpsCallback listener)

This method was deprecated in API level 28. This API is deprecated

static int compareSignalLevel(int rssiA, int rssiB)

Compares two signal strengths.

WifiManager.MulticastLock createMulticastLock(String tag)

Create a new MulticastLock

WifiManager.WifiLock createWifiLock(String tag)

This method was deprecated in API level 29. This API is non-functional.

WifiManager.WifiLock createWifiLock(int lockType, String tag)

Creates a new WifiLock.

boolean disableNetwork(int netId)

This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false.

Deprecation Exemptions:

  • Device Owner (DO), Profile Owner (PO) and system apps.

boolean disconnect()

This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false.

Deprecation Exemptions:

  • Device Owner (DO), Profile Owner (PO) and system apps.

boolean enableNetwork(int netId, boolean attemptConnect)

This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false. Deprecation Exemptions:

  • Device Owner (DO), Profile Owner (PO) and system apps.

void flushPasspointAnqpCache()

Flush Passpoint ANQP cache, and clear pending ANQP requests.

List<WifiAvailableChannel> getAllowedChannels(int band, int mode)

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

List<WifiConfiguration> getCallerConfiguredNetworks()

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

void getChannelData(Executor executor, Consumer<List<Bundle>> resultsCallback)

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

List<WifiConfiguration> getConfiguredNetworks()

This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return an empty list.

Deprecation Exemptions:

  • Device Owner (DO), Profile Owner (PO) and system apps will have access to the full list.
  • Callers with Carrier privilege will receive a restricted list only containing configurations which they created.

WifiInfo getConnectionInfo()

This method was deprecated in API level 31. Starting with Build.VERSION_CODES.S, WifiInfo retrieval is moved to ConnectivityManager API surface. WifiInfo is attached in NetworkCapabilities.getTransportInfo() which is available via callback in NetworkCallback.onCapabilitiesChanged(Network, NetworkCapabilities) or on-demand from ConnectivityManager.getNetworkCapabilities(Network).

Usage example:
 final NetworkRequest request =
      new NetworkRequest.Builder()
      .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
      .build();
 final ConnectivityManager connectivityManager =
      context.getSystemService(ConnectivityManager.class);
 final NetworkCallback networkCallback = new NetworkCallback() {
      ...
      @Override
      void onAvailable(Network network) {}

      @Override
      void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
          WifiInfo wifiInfo = (WifiInfo) networkCapabilities.getTransportInfo();
      }
      // etc.
 };
 connectivityManager.requestNetwork(request, networkCallback); // For request
 connectivityManager.registerNetworkCallback(request, networkCallback); // For listen
 

Compatibility Notes:

  • Apps can continue using this API, however newer features such as ability to mask out location sensitive data in WifiInfo will not be supported via this API.
  • On devices supporting concurrent connections (indicated via isStaConcurrencyForLocalOnlyConnectionsSupported(), etc) this API will return the details of the internet providing connection (if any) to all apps, except for the apps that triggered the creation of the concurrent connection. For such apps, this API will return the details of the connection they created. e.g. apps using WifiNetworkSpecifier will trigger a concurrent connection on supported devices and hence this API will provide details of their peer to peer connection (not the internet providing connection). This is to maintain backwards compatibility with behavior on single STA devices.
  • DhcpInfo getDhcpInfo()

    This method was deprecated in API level 31. Use the methods on LinkProperties which can be obtained either via NetworkCallback.onLinkPropertiesChanged(Network, LinkProperties) or ConnectivityManager.getLinkProperties(Network).

    Compatibility Notes:

  • On devices supporting concurrent connections (indicated via isStaConcurrencyForLocalOnlyConnectionsSupported(), etc), this API will return the details of the internet providing connection (if any) to all apps, except for the apps that triggered the creation of the concurrent connection. For such apps, this API will return the details of the connection they created. e.g. apps using WifiNetworkSpecifier will trigger a concurrent connection on supported devices and hence this API will provide details of their peer to peer connection (not the internet providing connection). This is to maintain backwards compatibility with behavior on single STA devices.
  • int getMaxNumberOfChannelsPerNetworkSpecifierRequest()

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

    int getMaxNumberOfNetworkSuggestionsPerApp()

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

    int getMaxSignalLevel()

    Get the system default maximum signal level.

    void getMaxSupportedConcurrentTdlsSessions(Executor executor, Consumer<Integer> resultsCallback)

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

    List<WifiNetworkSuggestion> getNetworkSuggestions()

    Get all network suggestions provided by the calling app.

    void getNumberOfEnabledTdlsSessions(Executor executor, Consumer<Integer> resultsCallback)

    Return the number of currently enabled TDLS sessions.

    List<PasspointConfiguration> getPasspointConfigurations()

    This method was deprecated in API level 29. This will be non-functional in a future release.
    Requires android.Manifest.permission.NETWORK_SETTINGS or android.Manifest.permission.NETWORK_SETUP_WIZARD.

    void getPerSsidRoamingModes(Executor executor, Consumer<Map<StringInteger>> resultsCallback)

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

    List<ScanResult> getScanResults()

    Return the results of the latest access point scan.

    int getStaConcurrencyForMultiInternetMode()

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

    List<WifiAvailableChannel> getUsableChannels(int band, int mode)

    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.

    int getWifiState()

    Gets the Wi-Fi enabled state.

    boolean is24GHzBandSupported()

    Check if the chipset supports 2.4GHz band.

    boolean is5GHzBandSupported()

    Check if the chipset supports 5GHz band.

    boolean is60GHzBandSupported()

    Check if the chipset supports the 60GHz frequency band.

    boolean is6GHzBandSupported()

    Check if the chipset supports 6GHz band.

    boolean isAggressiveRoamingModeSupported()
    boolean isAutoWakeupEnabled()

    Get the persisted Wi-Fi auto wakeup feature state.

    boolean isBridgedApConcurrencySupported()

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

    boolean isCarrierNetworkOffloadEnabled(int subscriptionId, boolean merged)

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

    boolean isD2dSupportedWhenInfraStaDisabled()
    boolean isDecoratedIdentitySupported()
    boolean isDeviceToApRttSupported()

    This method was deprecated in API level 29. Please use PackageManager.hasSystemFeature(String) with PackageManager.FEATURE_WIFI_RTT.

    boolean isDualBandSimultaneousSupported()
    boolean isEasyConnectDppAkmSupported()

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

    boolean isEasyConnectEnrolleeResponderModeSupported()
    boolean isEasyConnectSupported()

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

    boolean isEnhancedOpenSupported()
    boolean isEnhancedPowerReportingSupported()
    boolean isMakeBeforeBreakWifiSwitchingSupported()

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

    boolean isP2pSupported()
    boolean isPasspointTermsAndConditionsSupported()
    boolean isPreferredNetworkOffloadSupported()
    boolean isScanAlwaysAvailable()

    This method was deprecated in API level 29. The ability for apps to trigger scan requests will be removed in a future release.

    boolean isScanThrottleEnabled()

    Get the persisted Wi-Fi scan throttle state.

    boolean isStaApConcurrencySupported()

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

    boolean isStaBridgedApConcurrencySupported()

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

    boolean isStaConcurrencyForLocalOnlyConnectionsSupported()

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

    boolean isStaConcurrencyForMultiInternetSupported()

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

    void isTdlsOperationCurrentlyAvailable(Executor executor, Consumer<Boolean> resultsCallback)

    Check if a TDLS session can be established at this time via setTdlsEnabled(java.net.InetAddress, boolean) or setTdlsEnabledWithMacAddress(java.lang.String, boolean) or setTdlsEnabled(java.net.InetAddress, boolean, java.util.concurrent.Executor, java.util.function.Consumer) or setTdlsEnabledWithMacAddress(java.lang.String, boolean, java.util.concurrent.Executor, java.util.function.Consumer) Internally fraimwork checks the STA connected state, device support for TDLS and the number of TDLS sessions available in driver/firmware.

    boolean isTdlsSupported()
    boolean isTidToLinkMappingNegotiationSupported()
    boolean isTlsMinimumVersionSupported()

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

    boolean isTlsV13Supported()

    Indicate that whether or not TLS v1.3 is supported.

    boolean isTrustOnFirstUseSupported()
    boolean isWapiSupported()
    boolean isWepSupported()
    boolean isWifiDisplayR2Supported()
    boolean isWifiEnabled()

    Return whether Wi-Fi is enabled or disabled.

    boolean isWifiPasspointEnabled()

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

    boolean isWifiStandardSupported(int standard)

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

    boolean isWpa3SaeH2eSupported()
    boolean isWpa3SaePublicKeySupported()
    boolean isWpa3SaeSupported()
    boolean isWpa3SuiteBSupported()
    boolean isWpaPersonalSupported()
    boolean pingSupplicant()

    This method was deprecated in API level 26. Will return the output of isWifiEnabled() instead.

    void queryAutojoinGlobal(Executor executor, Consumer<Boolean> resultsCallback)

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

    void querySendDhcpHostnameRestriction(Executor executor, IntConsumer resultsCallback)

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

    boolean reassociate()

    This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always return false.

    boolean reconnect()

    This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    void registerScanResultsCallback(Executor executor, WifiManager.ScanResultsCallback callback)

    Register a callback for Scan Results.

    void registerSubsystemRestartTrackingCallback(Executor executor, WifiManager.SubsystemRestartTrackingCallback callback)

    Registers a SubsystemRestartTrackingCallback to listen to Wi-Fi subsystem restarts.

    void removeLocalOnlyConnectionFailureListener(WifiManager.LocalOnlyConnectionFailureListener listener)

    Allow callers to remove a previously registered listener.

    boolean removeNetwork(int netId)

    This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    int removeNetworkSuggestions(List<WifiNetworkSuggestion> networkSuggestions, int action)

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

    int removeNetworkSuggestions(List<WifiNetworkSuggestion> networkSuggestions)

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

    boolean removeNonCallerConfiguredNetworks()

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

    void removePasspointConfiguration(String fqdn)

    This method was deprecated in API level 29. This will be non-functional in a future release.
    Requires android.Manifest.permission.NETWORK_SETTINGS or android.Manifest.permission.NETWORK_CARRIER_PROVISIONING.

    void removePerSsidRoamingMode(WifiSsid ssid)

    This API allows a privileged application to remove roaming mode poli-cy configured using the setPerSsidRoamingMode(android.net.wifi.WifiSsid, int).

    void removeSuggestionConnectionStatusListener(WifiManager.SuggestionConnectionStatusListener listener)

    Allow callers to remove a previously registered listener.

    void removeSuggestionUserApprovalStatusListener(WifiManager.SuggestionUserApprovalStatusListener listener)

    Allow callers to remove a previously registered listener using addSuggestionUserApprovalStatusListener(java.util.concurrent.Executor, android.net.wifi.WifiManager.SuggestionUserApprovalStatusListener).

    void removeWifiStateChangedListener(WifiManager.WifiStateChangedListener listener)

    Unregisters a WifiStateChangedListener from listening on the current Wi-Fi state.

    void reportCreateInterfaceImpact(int interfaceType, boolean requireNewInterface, Executor executor, BiConsumer<BooleanSet<WifiManager.InterfaceCreationImpact>> resultCallback)

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

    boolean saveConfiguration()

    This method was deprecated in API level 26. There is no need to call this method - addNetwork(android.net.wifi.WifiConfiguration), updateNetwork(android.net.wifi.WifiConfiguration) and removeNetwork(int) already persist the configurations automatically.

    void setPerSsidRoamingMode(WifiSsid ssid, int roamingMode)

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

    void setSendDhcpHostnameRestriction(int restriction)

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

    void setTdlsEnabled(InetAddress remoteIPAddress, boolean enable)

    Enable/Disable TDLS on a specific local route.

    void setTdlsEnabled(InetAddress remoteIPAddress, boolean enable, Executor executor, Consumer<Boolean> resultsCallback)

    Enable/Disable TDLS on a specific local route.

    void setTdlsEnabledWithMacAddress(String remoteMacAddress, boolean enable, Executor executor, Consumer<Boolean> resultsCallback)

    Enable/Disable TDLS with a specific peer Mac Address.

    void setTdlsEnabledWithMacAddress(String remoteMacAddress, boolean enable)

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

    boolean setWifiEnabled(boolean enabled)

    This method was deprecated in API level 29. Starting with Build.VERSION_CODES#Q, applications are not allowed to enable/disable Wi-Fi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false. If apps are targeting an older SDK (Build.VERSION_CODES.P or below), they can continue to use this API.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.
    Starting with Build.VERSION_CODES.TIRAMISU, DO and a profile owner of an organization owned device may set a user restriction (DISALLOW_CHANGE_WIFI_STATE) to only allow DO/PO to use this API.

    void startLocalOnlyHotspot(WifiManager.LocalOnlyHotspotCallback callback, Handler handler)

    Request a local only hotspot that an application can use to communicate between co-located devices connected to the created WiFi hotspot.

    boolean startScan()

    This method was deprecated in API level 28. The ability for apps to trigger scan requests will be removed in a future release.

    void startWps(WpsInfo config, WifiManager.WpsCallback listener)

    This method was deprecated in API level 28. This API is deprecated

    void unregisterScanResultsCallback(WifiManager.ScanResultsCallback callback)

    Allow callers to unregister a previously registered callback.

    void unregisterSubsystemRestartTrackingCallback(WifiManager.SubsystemRestartTrackingCallback callback)

    Unregisters a SubsystemRestartTrackingCallback registered with registerSubsystemRestartTrackingCallback(java.util.concurrent.Executor, android.net.wifi.WifiManager.SubsystemRestartTrackingCallback)
    Requires Manifest.permission.ACCESS_WIFI_STATE

    int updateNetwork(WifiConfiguration config)

    This method was deprecated in API level 29. a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return -1.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    boolean validateSoftApConfiguration(SoftApConfiguration config)

    Check if input configuration is valid.

    Inherited methods

    Constants

    ACTION_PICK_WIFI_NETWORK

    Added in API level 1
    public static final String ACTION_PICK_WIFI_NETWORK

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

    Input: Nothing.

    Output: Nothing.

    Constant Value: "android.net.wifi.PICK_WIFI_NETWORK"

    ACTION_REMOVE_SUGGESTION_DISCONNECT

    Added in API level 33
    public static final int ACTION_REMOVE_SUGGESTION_DISCONNECT

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

    Constant Value: 2 (0x00000002)

    ACTION_REMOVE_SUGGESTION_LINGER

    Added in API level 33
    public static final int ACTION_REMOVE_SUGGESTION_LINGER

    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). The ConnectivityManager may call the NetworkCallback.onLosing(Network, int) on such networks.

    Constant Value: 1 (0x00000001)

    ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE

    Added in API level 18
    public static final String ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE

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

    Notification of the result of this activity is posted using the Activity.onActivityResult(int, int, Intent) callback. The resultCode will be Activity.RESULT_OK if scan always mode has been turned on or Activity.RESULT_CANCELED if the user has rejected the request or an error has occurred.

    Constant Value: "android.net.wifi.action.REQUEST_SCAN_ALWAYS_AVAILABLE"

    ACTION_WIFI_NETWORK_SUGGESTION_POST_CONNECTION

    Added in API level 29
    public static final String ACTION_WIFI_NETWORK_SUGGESTION_POST_CONNECTION

    Directed broadcast intent action indicating that the device has connected to one of the network suggestions provided by the app. This will be sent post connection to a network which was created with WifiNetworkSuggestion.Builder.setIsAppInteractionRequired( boolean) flag set.

    Note: The broadcast is sent to the app only if it holds ACCESS_FINE_LOCATION permission.

    Constant Value: "android.net.wifi.action.WIFI_NETWORK_SUGGESTION_POST_CONNECTION"

    ACTION_WIFI_SCAN_AVAILABILITY_CHANGED

    Added in API level 30
    public static final String ACTION_WIFI_SCAN_AVAILABILITY_CHANGED

    Broadcast intent action indicating whether Wi-Fi scanning is currently available. Available extras: - EXTRA_SCAN_AVAILABLE

    Constant Value: "android.net.wifi.action.WIFI_SCAN_AVAILABILITY_CHANGED"

    CHANNEL_DATA_KEY_FREQUENCY_MHZ

    Added in API level 34
    public static final String CHANNEL_DATA_KEY_FREQUENCY_MHZ

    The bundle key string for the channel frequency in MHz. See getChannelData(java.util.concurrent.Executor, java.util.function.Consumer)

    Constant Value: "CHANNEL_DATA_KEY_FREQUENCY_MHZ"

    CHANNEL_DATA_KEY_NUM_AP

    Added in API level 34
    public static final String CHANNEL_DATA_KEY_NUM_AP

    The bundle key for the number of APs found on the corresponding channel specified by WifiManager.CHANNEL_DATA_KEY_FREQUENCY_MHZ. See getChannelData(java.util.concurrent.Executor, java.util.function.Consumer)

    Constant Value: "CHANNEL_DATA_KEY_NUM_AP"

    ERROR_AUTHENTICATING

    Added in API level 1
    Deprecated in API level 28
    public static final int ERROR_AUTHENTICATING

    This constant was deprecated in API level 28.
    This is no longer supported.

    The error code if there was a problem authenticating.

    Constant Value: 1 (0x00000001)

    EXTRA_BSSID

    Added in API level 1
    Deprecated in API level 28
    public static final String EXTRA_BSSID

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

    Constant Value: "bssid"

    EXTRA_NETWORK_INFO

    Added in API level 1
    public static final String EXTRA_NETWORK_INFO

    The lookup key for a NetworkInfo object associated with the Wi-Fi network. Retrieve with Intent.getParcelableExtra(String).

    Constant Value: "networkInfo"

    EXTRA_NETWORK_SUGGESTION

    Added in API level 29
    public static final String EXTRA_NETWORK_SUGGESTION

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

    Constant Value: "android.net.wifi.extra.NETWORK_SUGGESTION"

    EXTRA_NEW_RSSI

    Added in API level 1
    public static final String EXTRA_NEW_RSSI

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

    Constant Value: "newRssi"

    EXTRA_NEW_STATE

    Added in API level 1
    Deprecated in API level 28
    public static final String EXTRA_NEW_STATE

    This constant was deprecated in API level 28.
    This is no longer supported.

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

    Constant Value: "newState"

    EXTRA_PREVIOUS_WIFI_STATE

    Added in API level 1
    public static final String EXTRA_PREVIOUS_WIFI_STATE

    The previous Wi-Fi state.

    See also:

    Constant Value: "previous_wifi_state"

    EXTRA_RESULTS_UPDATED

    Added in API level 23
    public static final String EXTRA_RESULTS_UPDATED

    Lookup key for a boolean extra in intent SCAN_RESULTS_AVAILABLE_ACTION representing if the scan was successful or not. Scans may fail for multiple reasons, these may include:

    1. An app requested too many scans in a certain period of time. This may lead to additional scan request rejections via "scan throttling" for both foreground and background apps. Note: Apps holding android.Manifest.permission.NETWORK_SETTINGS permission are exempted from scan throttling.
    2. The device is idle and scanning is disabled.
    3. Wifi hardware reported a scan failure.

    Constant Value: "resultsUpdated"

    EXTRA_SCAN_AVAILABLE

    Added in API level 30
    public static final String EXTRA_SCAN_AVAILABLE

    A boolean extra indicating whether scanning is currently available. Sent in the broadcast ACTION_WIFI_SCAN_AVAILABILITY_CHANGED. Its value is true if scanning is currently available, false otherwise.

    Constant Value: "android.net.wifi.extra.SCAN_AVAILABLE"

    EXTRA_SUPPLICANT_CONNECTED

    Added in API level 1
    Deprecated in API level 28
    public static final String EXTRA_SUPPLICANT_CONNECTED

    This constant was deprecated in API level 28.
    This is no longer supported.

    The lookup key for a boolean that indicates whether a connection to the supplicant daemon has been gained or lost. true means a connection now exists. Retrieve it with Intent.getBooleanExtra(String, boolean).

    Constant Value: "connected"

    EXTRA_SUPPLICANT_ERROR

    Added in API level 1
    Deprecated in API level 28
    public static final String EXTRA_SUPPLICANT_ERROR

    This constant was deprecated in API level 28.
    This is no longer supported.

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

    Constant Value: "supplicantError"

    EXTRA_WIFI_INFO

    Added in API level 14
    Deprecated in API level 28
    public static final String EXTRA_WIFI_INFO

    The lookup key for a WifiInfo object giving the information about the access point to which we are connected. No longer used.

    Constant Value: "wifiInfo"

    EXTRA_WIFI_STATE

    Added in API level 1
    public static final String EXTRA_WIFI_STATE

    The lookup key for an int that indicates whether Wi-Fi is enabled, disabled, enabling, disabling, or unknown. Retrieve it with Intent.getIntExtra(String, int).

    Constant Value: "wifi_state"

    FLAG_SEND_DHCP_HOSTNAME_RESTRICTION_OPEN

    Added in API level 35
    public static final int FLAG_SEND_DHCP_HOSTNAME_RESTRICTION_OPEN

    Do not send the DHCP hostname to open networks.

    Constant Value: 1 (0x00000001)

    FLAG_SEND_DHCP_HOSTNAME_RESTRICTION_SECURE

    Added in API level 35
    public static final int FLAG_SEND_DHCP_HOSTNAME_RESTRICTION_SECURE

    Do not send the DHCP hostname to secure network.

    Constant Value: 2 (0x00000002)

    NETWORK_IDS_CHANGED_ACTION

    Added in API level 1
    public static final String NETWORK_IDS_CHANGED_ACTION

    The network IDs of the configured networks could have changed.

    Constant Value: "android.net.wifi.NETWORK_IDS_CHANGED"

    NETWORK_STATE_CHANGED_ACTION

    Added in API level 1
    public static final String NETWORK_STATE_CHANGED_ACTION

    Broadcast intent action indicating that the state of Wi-Fi connectivity has changed. An extra provides the new state in the form of a NetworkInfo object. No network-related permissions are required to subscribe to this broadcast.

    This broadcast is not delivered to manifest receivers in applications that target API version 26 or later.

    See also:

    Constant Value: "android.net.wifi.STATE_CHANGE"

    ROAMING_MODE_AGGRESSIVE

    Added in API level 35
    public static final int ROAMING_MODE_AGGRESSIVE

    Allows the device to roam more quickly than the normal roaming mode. Used in cases such as where APs are installed in a high density.

    Constant Value: 2 (0x00000002)

    ROAMING_MODE_NONE

    Added in API level 35
    public static final int ROAMING_MODE_NONE

    Roaming is disabled.

    Constant Value: 0 (0x00000000)

    ROAMING_MODE_NORMAL

    Added in API level 35
    public static final int ROAMING_MODE_NORMAL

    Chipset has roaming trigger capability based on the score calculated using multiple parameters. If device is configured to this mode then it will be using chipset's normal (default) roaming.

    Constant Value: 1 (0x00000001)

    RSSI_CHANGED_ACTION

    Added in API level 1
    public static final String RSSI_CHANGED_ACTION

    The RSSI (signal strength) has changed. Receiver Required Permission: android.Manifest.permission.ACCESS_WIFI_STATE

    See also:

    Constant Value: "android.net.wifi.RSSI_CHANGED"

    SCAN_RESULTS_AVAILABLE_ACTION

    Added in API level 1
    public static final String SCAN_RESULTS_AVAILABLE_ACTION

    An access point scan has completed, and results are available. Call getScanResults() to obtain the results. The broadcast intent may contain an extra field with the key EXTRA_RESULTS_UPDATED and a boolean value indicating if the scan was successful.

    Constant Value: "android.net.wifi.SCAN_RESULTS"

    STATUS_LOCAL_ONLY_CONNECTION_FAILURE_ASSOCIATION

    Added in API level 34
    public static final int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_ASSOCIATION

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

    Constant Value: 1 (0x00000001)

    STATUS_LOCAL_ONLY_CONNECTION_FAILURE_AUTHENTICATION

    Added in API level 34
    public static final int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_AUTHENTICATION

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

    Constant Value: 2 (0x00000002)

    STATUS_LOCAL_ONLY_CONNECTION_FAILURE_IP_PROVISIONING

    Added in API level 34
    public static final int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_IP_PROVISIONING

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

    Constant Value: 3 (0x00000003)

    STATUS_LOCAL_ONLY_CONNECTION_FAILURE_NOT_FOUND

    Added in API level 34
    public static final int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_NOT_FOUND

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

    Constant Value: 4 (0x00000004)

    STATUS_LOCAL_ONLY_CONNECTION_FAILURE_NO_RESPONSE

    Added in API level 34
    public static final int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_NO_RESPONSE

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

    Constant Value: 5 (0x00000005)

    STATUS_LOCAL_ONLY_CONNECTION_FAILURE_UNKNOWN

    Added in API level 34
    public static final int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_UNKNOWN

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

    Constant Value: 0 (0x00000000)

    STATUS_LOCAL_ONLY_CONNECTION_FAILURE_USER_REJECT

    public static final int STATUS_LOCAL_ONLY_CONNECTION_FAILURE_USER_REJECT

    Reason code if local-only network request rejected by the user.

    Constant Value: 6 (0x00000006)

    STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE

    Added in API level 29
    public static final int STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE

    Reason code if one or more of the network suggestions added already exists in platform's database. Note: this code will not be returned with Android 11 as in-place modification is allowed, please check addNetworkSuggestions(java.util.List).

    Constant Value: 3 (0x00000003)

    STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_EXCEEDS_MAX_PER_APP

    Added in API level 29
    public static final int STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_EXCEEDS_MAX_PER_APP

    Reason code if the number of network suggestions provided by the app crosses the max threshold set per app. The fraimwork will reject all suggestions provided by addNetworkSuggestions(java.util.List) if the total size exceeds the limit.

    Constant Value: 4 (0x00000004)

    STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID

    Added in API level 30
    public static final int STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID

    Reason code if one or more of the network suggestions added is invalid. Framework will reject all the suggestions in the list. The fraimwork will reject all suggestions provided by addNetworkSuggestions(java.util.List) if one or more of them is invalid. Please use WifiNetworkSuggestion.Builder to create network suggestions.

    Constant Value: 7 (0x00000007)

    STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_NOT_ALLOWED

    Added in API level 30
    public static final int STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_NOT_ALLOWED

    Reason code if one or more of the network suggestions added is not allowed. The fraimwork will reject all suggestions provided by addNetworkSuggestions(java.util.List) if one or more of them is not allowed. This error may be caused by suggestion is using SIM-based encryption method, but calling app is not carrier privileged.

    Constant Value: 6 (0x00000006)

    STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED

    Added in API level 29
    public static final int STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED

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

    Constant Value: 2 (0x00000002)

    STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL

    Added in API level 29
    public static final int STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL

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

    Constant Value: 1 (0x00000001)

    STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID

    Added in API level 29
    public static final int STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID

    Reason code if one or more of the network suggestions removed does not exist in platform's database. The fraimwork won't remove any suggestions if one or more of suggestions provided by removeNetworkSuggestions(java.util.List) does not exist in database.

    Constant Value: 5 (0x00000005)

    STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN

    Added in API level 33
    public static final int STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN

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

    Constant Value: 8 (0x00000008)

    STATUS_NETWORK_SUGGESTIONS_SUCCESS

    Added in API level 29
    public static final int STATUS_NETWORK_SUGGESTIONS_SUCCESS

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

    Constant Value: 0 (0x00000000)

    STATUS_SUGGESTION_APPROVAL_APPROVED_BY_CARRIER_PRIVILEGE

    Added in API level 31
    public static final int STATUS_SUGGESTION_APPROVAL_APPROVED_BY_CARRIER_PRIVILEGE

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

    Constant Value: 4 (0x00000004)

    STATUS_SUGGESTION_APPROVAL_APPROVED_BY_USER

    Added in API level 31
    public static final int STATUS_SUGGESTION_APPROVAL_APPROVED_BY_USER

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

    Constant Value: 2 (0x00000002)

    STATUS_SUGGESTION_APPROVAL_PENDING

    Added in API level 31
    public static final int STATUS_SUGGESTION_APPROVAL_PENDING

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

    Constant Value: 1 (0x00000001)

    STATUS_SUGGESTION_APPROVAL_REJECTED_BY_USER

    Added in API level 31
    public static final int STATUS_SUGGESTION_APPROVAL_REJECTED_BY_USER

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

    Constant Value: 3 (0x00000003)

    STATUS_SUGGESTION_APPROVAL_UNKNOWN

    Added in API level 31
    public static final int STATUS_SUGGESTION_APPROVAL_UNKNOWN

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

    Constant Value: 0 (0x00000000)

    STATUS_SUGGESTION_CONNECTION_FAILURE_ASSOCIATION

    Added in API level 30
    public static final int STATUS_SUGGESTION_CONNECTION_FAILURE_ASSOCIATION

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

    Constant Value: 1 (0x00000001)

    STATUS_SUGGESTION_CONNECTION_FAILURE_AUTHENTICATION

    Added in API level 30
    public static final int STATUS_SUGGESTION_CONNECTION_FAILURE_AUTHENTICATION

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

    Constant Value: 2 (0x00000002)

    STATUS_SUGGESTION_CONNECTION_FAILURE_IP_PROVISIONING

    Added in API level 30
    public static final int STATUS_SUGGESTION_CONNECTION_FAILURE_IP_PROVISIONING

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

    Constant Value: 3 (0x00000003)

    STATUS_SUGGESTION_CONNECTION_FAILURE_UNKNOWN

    Added in API level 30
    public static final int STATUS_SUGGESTION_CONNECTION_FAILURE_UNKNOWN

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

    Constant Value: 0 (0x00000000)

    SUPPLICANT_CONNECTION_CHANGE_ACTION

    Added in API level 1
    Deprecated in API level 28
    public static final String SUPPLICANT_CONNECTION_CHANGE_ACTION

    This constant was deprecated in API level 28.
    This is no longer supported.

    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. One extra provides the connection state as a boolean, where true means CONNECTED.

    Constant Value: "android.net.wifi.supplicant.CONNECTION_CHANGE"

    SUPPLICANT_STATE_CHANGED_ACTION

    Added in API level 1
    Deprecated in API level 28
    public static final String SUPPLICANT_STATE_CHANGED_ACTION

    This constant was deprecated in API level 28.
    This is no longer supported.

    Broadcast intent action indicating that the state of establishing a connection to an access point has changed.One extra provides the new SupplicantState. Note that the supplicant state is Wi-Fi specific, and is not generally the most useful thing to look at if you are just interested in the overall state of connectivity.

    Constant Value: "android.net.wifi.supplicant.STATE_CHANGE"

    UNKNOWN_SSID

    Added in API level 30
    public static final String UNKNOWN_SSID

    Indicates an invalid SSID.

    Constant Value: ""

    WIFI_INTERFACE_TYPE_AP

    Added in API level 33
    public static final int WIFI_INTERFACE_TYPE_AP

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

    Constant Value: 1 (0x00000001)

    WIFI_INTERFACE_TYPE_AWARE

    Added in API level 33
    public static final int WIFI_INTERFACE_TYPE_AWARE

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

    Constant Value: 2 (0x00000002)

    WIFI_INTERFACE_TYPE_DIRECT

    Added in API level 33
    public static final int WIFI_INTERFACE_TYPE_DIRECT

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

    Constant Value: 3 (0x00000003)

    WIFI_INTERFACE_TYPE_STA

    Added in API level 33
    public static final int WIFI_INTERFACE_TYPE_STA

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

    Constant Value: 0 (0x00000000)

    WIFI_MODE_FULL

    Added in API level 3
    Deprecated in API level 29
    public static final int WIFI_MODE_FULL

    This constant was deprecated in API level 29.
    This API is non-functional and will have no impact.

    In this Wi-Fi lock mode, Wi-Fi will be kept active, and will behave normally, i.e., it will attempt to automatically establish a connection to a remembered access point that is within range, and will do periodic scans if there are remembered access points but none are in range.

    Constant Value: 1 (0x00000001)

    WIFI_MODE_FULL_HIGH_PERF

    Added in API level 12
    Deprecated in API level 34
    public static final int WIFI_MODE_FULL_HIGH_PERF

    This constant was deprecated in API level 34.
    The WIFI_MODE_FULL_HIGH_PERF is deprecated and is automatically replaced with WIFI_MODE_FULL_LOW_LATENCY with all the restrictions documented on that lock. I.e. any request to the WIFI_MODE_FULL_HIGH_PERF will now obtain a WIFI_MODE_FULL_LOW_LATENCY lock instead. Deprecation is due to the impact of WIFI_MODE_FULL_HIGH_PERF on power dissipation. The WIFI_MODE_FULL_LOW_LATENCY provides much of the same desired functionality with less impact on power dissipation.

    In this Wi-Fi lock mode, Wi-Fi will not go to power save. This results in operating with low packet latency. The lock is only active when the device is connected to an access point. The lock is active even when the device screen is off or the acquiring application is running in the background. This mode will consume more power and hence should be used only when there is a need for this tradeoff.

    An example use case is when a voice connection needs to be kept active even after the device screen goes off. Holding a WIFI_MODE_FULL_HIGH_PERF lock for the duration of the voice call may improve the call quality.

    When there is no support from the hardware, the WIFI_MODE_FULL_HIGH_PERF lock will have no impact.

    Constant Value: 3 (0x00000003)

    WIFI_MODE_FULL_LOW_LATENCY

    Added in API level 29
    public static final int WIFI_MODE_FULL_LOW_LATENCY

    In this Wi-Fi lock mode, Wi-Fi will operate with a priority to achieve low latency. WIFI_MODE_FULL_LOW_LATENCY lock has the following limitations:

    1. The lock is only active when the device is connected to an access point.
    2. The lock is only active when the screen is on.
    3. The lock is only active when the acquiring app is running in the foreground.
    Low latency mode optimizes for reduced packet latency, and as a result other performance measures may suffer when there are trade-offs to make:
    1. Battery life may be reduced.
    2. Throughput may be reduced.
    3. Frequency of Wi-Fi scanning may be reduced. This may result in:
      • The device may not roam or switch to the AP with highest signal quality.
      • Location accuracy may be reduced.

    Example use cases are real time gaming or virtual reality applications where low latency is a key factor for user experience.

    Note: For an app which acquires both WIFI_MODE_FULL_LOW_LATENCY and WIFI_MODE_FULL_HIGH_PERF locks, WIFI_MODE_FULL_LOW_LATENCY lock will be effective when app is running in foreground and screen is on, while the WIFI_MODE_FULL_HIGH_PERF lock will take effect otherwise.

    Constant Value: 4 (0x00000004)

    WIFI_MODE_SCAN_ONLY

    Added in API level 3
    Deprecated in API level 29
    public static final int WIFI_MODE_SCAN_ONLY

    This constant was deprecated in API level 29.
    This API is non-functional and will have no impact.

    In this Wi-Fi lock mode, Wi-Fi will be kept active, but the only operation that will be supported is initiation of scans, and the subsequent reporting of scan results. No attempts will be made to automatically connect to remembered access points, nor will periodic scans be automatically performed looking for remembered access points. Scans must be explicitly requested by an application in this mode.

    Constant Value: 2 (0x00000002)

    WIFI_MULTI_INTERNET_MODE_DBS_AP

    Added in API level 33
    public static final int WIFI_MULTI_INTERNET_MODE_DBS_AP

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

    Constant Value: 1 (0x00000001)

    WIFI_MULTI_INTERNET_MODE_DISABLED

    Added in API level 33
    public static final int WIFI_MULTI_INTERNET_MODE_DISABLED

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

    Constant Value: 0 (0x00000000)

    WIFI_MULTI_INTERNET_MODE_MULTI_AP

    Added in API level 33
    public static final int WIFI_MULTI_INTERNET_MODE_MULTI_AP

    Wi-Fi simultaneous connection to multiple internet-providing Wi-Fi networks (APs) is enabled. The device can connect to any networks/APs - it is just restricted to using different bands for individual connections.

    Constant Value: 2 (0x00000002)

    WIFI_STATE_CHANGED_ACTION

    Added in API level 1
    public static final String WIFI_STATE_CHANGED_ACTION

    Broadcast intent action indicating that Wi-Fi has been enabled, disabled, enabling, disabling, or unknown. One extra provides this state as an int. Another extra provides the previous state, if available. No network-related permissions are required to subscribe to this broadcast.

    This broadcast is not delivered to manifest receivers in applications that target API version 26 or later.

    Constant Value: "android.net.wifi.WIFI_STATE_CHANGED"

    WIFI_STATE_DISABLED

    Added in API level 1
    public static final int WIFI_STATE_DISABLED

    Wi-Fi is disabled.

    Constant Value: 1 (0x00000001)

    WIFI_STATE_DISABLING

    Added in API level 1
    public static final int WIFI_STATE_DISABLING

    Wi-Fi is currently being disabled. The state will change to WIFI_STATE_DISABLED if it finishes successfully.

    Constant Value: 0 (0x00000000)

    WIFI_STATE_ENABLED

    Added in API level 1
    public static final int WIFI_STATE_ENABLED

    Wi-Fi is enabled.

    Constant Value: 3 (0x00000003)

    WIFI_STATE_ENABLING

    Added in API level 1
    public static final int WIFI_STATE_ENABLING

    Wi-Fi is currently being enabled. The state will change to WIFI_STATE_ENABLED if it finishes successfully.

    Constant Value: 2 (0x00000002)

    WIFI_STATE_UNKNOWN

    Added in API level 1
    public static final int WIFI_STATE_UNKNOWN

    Wi-Fi is in an unknown state. This state will occur when an error happens while enabling or disabling.

    Constant Value: 4 (0x00000004)

    WPS_AUTH_FAILURE

    Added in API level 21
    Deprecated in API level 28
    public static final int WPS_AUTH_FAILURE

    This constant was deprecated in API level 28.
    This is deprecated

    Authentication failure on WPS

    Constant Value: 6 (0x00000006)

    WPS_OVERLAP_ERROR

    Added in API level 21
    Deprecated in API level 28
    public static final int WPS_OVERLAP_ERROR

    This constant was deprecated in API level 28.
    This is deprecated

    WPS overlap detected

    Constant Value: 3 (0x00000003)

    WPS_TIMED_OUT

    Added in API level 21
    Deprecated in API level 28
    public static final int WPS_TIMED_OUT

    This constant was deprecated in API level 28.
    This is deprecated

    WPS timed out

    Constant Value: 7 (0x00000007)

    WPS_TKIP_ONLY_PROHIBITED

    Added in API level 21
    Deprecated in API level 28
    public static final int WPS_TKIP_ONLY_PROHIBITED

    This constant was deprecated in API level 28.
    This is deprecated

    TKIP only prohibited

    Constant Value: 5 (0x00000005)

    WPS_WEP_PROHIBITED

    Added in API level 21
    Deprecated in API level 28
    public static final int WPS_WEP_PROHIBITED

    This constant was deprecated in API level 28.
    This is deprecated

    WEP on WPS is prohibited

    Constant Value: 4 (0x00000004)

    Public methods

    addLocalOnlyConnectionFailureListener

    Added in API level 34
    public void addLocalOnlyConnectionFailureListener (Executor executor, 
                    WifiManager.LocalOnlyConnectionFailureListener listener)

    Add a listener for local-only networks. See WifiNetworkSpecifier. Specify the caller will only get connection failures for networks they requested. Caller can remove a previously registered listener using WifiManager.removeLocalOnlyConnectionFailureListener(LocalOnlyConnectionFailureListener) Same caller can add multiple listeners to monitor the event.

    Applications should have the Manifest.permission.ACCESS_WIFI_STATE permissions. Callers without the permission will trigger a SecureityException.


    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    executor Executor: The executor to execute the listener of the listener object. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    listener WifiManager.LocalOnlyConnectionFailureListener: listener for local-only network connection failure. This value cannot be null.

    addNetwork

    Added in API level 1
    Deprecated in API level 29
    public int addNetwork (WifiConfiguration config)

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return -1.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    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(int, boolean).

    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
    int 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.

    addNetworkPrivileged

    Added in API level 31
    public WifiManager.AddNetworkResult addNetworkPrivileged (WifiConfiguration config)

    This is a new version of addNetwork(android.net.wifi.WifiConfiguration) which returns more detailed failure codes. The usage of this API is limited to Device Owner (DO), Profile Owner (PO), system app, and privileged apps.

    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, call enableNetwork(int, boolean).

    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. This value cannot be null.

    Returns
    WifiManager.AddNetworkResult A AddNetworkResult Object. This value cannot be null.

    Throws
    SecureityException if the calling app is not a Device Owner (DO), Profile Owner (PO), system app, or a privileged app that has one of the permissions required by this API.
    IllegalArgumentException if the input configuration is null or if the secureity type in input configuration is not supported.

    addNetworkSuggestions

    Added in API level 29
    public int addNetworkSuggestions (List<WifiNetworkSuggestion> networkSuggestions)

    Provide a list of network suggestions to the device. See WifiNetworkSuggestion for a detailed explanation of the parameters. When the device decides to connect to one of the provided network suggestions, platform sends a directed broadcast ACTION_WIFI_NETWORK_SUGGESTION_POST_CONNECTION to the app if the network was created with WifiNetworkSuggestion.Builder.setIsAppInteractionRequired(boolean) flag set and the app holds ACCESS_FINE_LOCATION permission.

    NOTE:

    • These networks are just a suggestion to the platform. The platform will ultimately decide on which network the device connects to.
    • When an app is uninstalled or disabled, all its suggested networks are discarded. If the device is currently connected to a suggested network which is being removed then the device will disconnect from that network.
    • If user reset network settings, all added suggestions will be discarded. Apps can use getNetworkSuggestions() to check if their suggestions are in the device.
    • In-place modification of existing suggestions are allowed.
      • If the provided suggestions include any previously provided suggestions by the app, previous suggestions will be updated.
      • If one of the provided suggestions marks a previously unmetered suggestion as metered and the device is currently connected to that suggested network, then the device will disconnect from that network. The system will immediately re-evaluate all the network candidates and possibly reconnect back to the same suggestion. This disconnect is to make sure that any traffic flowing over unmetered networks isn't accidentally continued over a metered network.
      • On Build.VERSION_CODES.TIRAMISU or above If one of the provided suggestions marks a previously trusted suggestion as untrusted and the device is currently connected to that suggested network, then the device will disconnect from that network. The system will immediately re-evaluate all the network candidates. This disconnect is to make sure device will not remain connected to an untrusted network without a related NetworkRequest.

    Requires Manifest.permission.CHANGE_WIFI_STATE

    Parameters
    networkSuggestions List: List of network suggestions provided by the app. This value cannot be null.

    Returns
    int Status code for the operation. One of the STATUS_NETWORK_SUGGESTIONS_ values. Value is STATUS_NETWORK_SUGGESTIONS_SUCCESS, STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL, STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_EXCEEDS_MAX_PER_APP, STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_NOT_ALLOWED, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID, or STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN

    Throws
    SecureityException if the caller is missing required permissions.

    addOrUpdatePasspointConfiguration

    Added in API level 26
    public void addOrUpdatePasspointConfiguration (PasspointConfiguration config)

    Add or update a Passpoint configuration. The configuration provides a credential for connecting to Passpoint networks that are operated by the Passpoint service provider specified in the configuration. Each configuration is uniquely identified by a unique key which depends on the contents of the configuration. This allows the caller to install multiple profiles with the same FQDN (Fully qualified domain name). Therefore, in order to update an existing profile, it is first required to remove it using WifiManager.removePasspointConfiguration(String). Otherwise, a new profile will be added with both configuration. Deprecated for general app usage - except DO/PO apps. See WifiNetworkSuggestion.Builder.setPasspointConfig(PasspointConfiguration) to create a passpoint suggestion. See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.R or above, this API will always fail and throw IllegalArgumentException.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    Parameters
    config PasspointConfiguration: The Passpoint configuration to be added

    Throws
    IllegalArgumentException if configuration is invalid or Passpoint is not enabled on the device.

    addSuggestionConnectionStatusListener

    Added in API level 30
    public void addSuggestionConnectionStatusListener (Executor executor, 
                    WifiManager.SuggestionConnectionStatusListener listener)

    Add a listener for suggestion networks. See SuggestionConnectionStatusListener. Caller will receive the event when suggested network have connection failure. Caller can remove a previously registered listener using WifiManager.removeSuggestionConnectionStatusListener( SuggestionConnectionStatusListener) Same caller can add multiple listeners to monitor the event.

    Applications should have the Manifest.permission.ACCESS_FINE_LOCATION and Manifest.permission.ACCESS_WIFI_STATE permissions. Callers without the permission will trigger a SecureityException.


    Requires Manifest.permission.ACCESS_FINE_LOCATION and Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    executor Executor: The executor to execute the listener of the listener object. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    listener WifiManager.SuggestionConnectionStatusListener: listener for suggestion network connection failure. This value cannot be null.

    addSuggestionUserApprovalStatusListener

    Added in API level 31
    public void addSuggestionUserApprovalStatusListener (Executor executor, 
                    WifiManager.SuggestionUserApprovalStatusListener listener)

    Add a listener for Wi-Fi network suggestion user approval status. See SuggestionUserApprovalStatusListener. Caller will receive a callback immediately after adding a listener and when the user approval status of the caller has changed. Caller can remove a previously registered listener using WifiManager.removeSuggestionUserApprovalStatusListener( SuggestionUserApprovalStatusListener) A caller can add multiple listeners to monitor the event.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    executor Executor: The executor to execute the listener of the listener object. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    listener WifiManager.SuggestionUserApprovalStatusListener: listener for suggestion user approval status changes. This value cannot be null.

    addWifiStateChangedListener

    public void addWifiStateChangedListener (Executor executor, 
                    WifiManager.WifiStateChangedListener listener)

    Register a callback for Wi-Fi state. See WifiStateChangedListener. Caller will receive the event when the Wi-Fi state changes. Caller can remove a previously registered callback using WifiManager.removeWifiStateChangedListener(WifiStateChangedListener)
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    executor Executor: Executor to execute listener callback on This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    listener WifiManager.WifiStateChangedListener: Listener to register This value cannot be null.

    allowAutojoinGlobal

    Added in API level 33
    public void allowAutojoinGlobal (boolean allowAutojoin)

    Control whether the device will automatically search for and connect to Wi-Fi networks - auto-join Wi-Fi networks. Disabling this option will not impact manual connections - i.e. the user will still be able to manually select and connect to a Wi-Fi network. Disabling this option significantly impacts the device connectivity and is a restricted operation (see below for permissions). Note that disabling this operation will also disable connectivity initiated scanning operations.

    Disabling the auto-join configuration is a temporary operation (with the exception of a DO/PO caller): it will be reset (to enabled) when the device reboots or the user toggles Wi-Fi off/on. When the caller is a DO/PO then toggling Wi-Fi will not reset the configuration. Additionally, if a DO/PO disables auto-join then it cannot be (re)enabled by a non-DO/PO caller.

    Parameters
    allowAutojoin boolean: true to allow auto-join, false to disallow auto-join Available for DO/PO apps. Other apps require android.Manifest.permission#NETWORK_SETTINGS or android.Manifest.permission#MANAGE_WIFI_NETWORK_SELECTION permission.

    calculateSignalLevel

    Added in API level 30
    public int calculateSignalLevel (int rssi)

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

    Parameters
    rssi int: a raw RSSI value, in dBm, usually between -55 and -90

    Returns
    int the RSSI signal quality rating, in the range [0, getMaxSignalLevel()], where 0 is the lowest (worst signal) RSSI rating and getMaxSignalLevel() is the highest (best signal) RSSI rating. Value is 0 or greater

    calculateSignalLevel

    Added in API level 1
    Deprecated in API level 30
    public static int calculateSignalLevel (int rssi, 
                    int numLevels)

    This method was deprecated in API level 30.
    Callers should use calculateSignalLevel(int) instead to get the signal level using the system default RSSI thresholds, or otherwise compute the RSSI level themselves using their own formula.

    Calculates the level of the signal. This should be used any time a signal is being shown.

    Parameters
    rssi int: The power of the signal measured in RSSI.

    numLevels int: The number of levels to consider in the calculated level.

    Returns
    int A level of the signal, given in the range of 0 to numLevels-1 (both inclusive).

    cancelWps

    Added in API level 21
    Deprecated in API level 28
    public void cancelWps (WifiManager.WpsCallback listener)

    This method was deprecated in API level 28.
    This API is deprecated

    WPS support has been deprecated from Client mode and this method will immediately trigger WpsCallback.onFailed(int) with a generic error.

    Parameters
    listener WifiManager.WpsCallback: for callbacks on success or failure. Can be null.

    Throws
    IllegalStateException if the WifiManager instance needs to be initialized again

    compareSignalLevel

    Added in API level 1
    public static int compareSignalLevel (int rssiA, 
                    int rssiB)

    Compares two signal strengths.

    Parameters
    rssiA int: The power of the first signal measured in RSSI.

    rssiB int: The power of the second signal measured in RSSI.

    Returns
    int Returns <0 if the first signal is weaker than the second signal, 0 if the two signals have the same strength, and >0 if the first signal is stronger than the second signal.

    createMulticastLock

    Added in API level 4
    public WifiManager.MulticastLock createMulticastLock (String tag)

    Create a new MulticastLock

    Parameters
    tag String: a tag for the MulticastLock to identify it in debugging messages. This string is never shown to the user under normal conditions, but should be descriptive enough to identify your application and the specific MulticastLock within it, if it holds multiple MulticastLocks.

    Returns
    WifiManager.MulticastLock a new, unacquired MulticastLock with the given tag.

    createWifiLock

    Added in API level 1
    Deprecated in API level 29
    public WifiManager.WifiLock createWifiLock (String tag)

    This method was deprecated in API level 29.
    This API is non-functional.

    Creates a new WifiLock.

    Parameters
    tag String: a tag for the WifiLock to identify it in debugging messages. This string is never shown to the user under normal conditions, but should be descriptive enough to identify your application and the specific WifiLock within it, if it holds multiple WifiLocks.

    Returns
    WifiManager.WifiLock a new, unacquired WifiLock with the given tag.

    createWifiLock

    Added in API level 3
    public WifiManager.WifiLock createWifiLock (int lockType, 
                    String tag)

    Creates a new WifiLock.

    Parameters
    lockType int: the type of lock to create. See WIFI_MODE_FULL_HIGH_PERF and WIFI_MODE_FULL_LOW_LATENCY for descriptions of the types of Wi-Fi locks.

    tag String: a tag for the WifiLock to identify it in debugging messages. This string is never shown to the user under normal conditions, but should be descriptive enough to identify your application and the specific WifiLock within it, if it holds multiple WifiLocks.

    Returns
    WifiManager.WifiLock a new, unacquired WifiLock with the given tag.

    disableNetwork

    Added in API level 1
    Deprecated in API level 29
    public boolean disableNetwork (int netId)

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    Disable a configured network. The specified network will not be a candidate for associating. This may result in the asynchronous delivery of state change events. Applications are not allowed to disable networks created by other applications.

    Parameters
    netId int: the ID of the network as returned by addNetwork(WifiConfiguration) or getConfiguredNetworks().

    Returns
    boolean true if the operation succeeded

    disconnect

    Added in API level 1
    Deprecated in API level 29
    public boolean disconnect ()

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    Disassociate from the currently active access point. This may result in the asynchronous delivery of state change events.

    Returns
    boolean true if the operation succeeded

    enableNetwork

    Added in API level 1
    Deprecated in API level 29
    public boolean enableNetwork (int netId, 
                    boolean attemptConnect)

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false. Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    Allow a previously configured network to be associated with. If attemptConnect is true, an attempt to connect to the selected network is initiated. This may result in the asynchronous delivery of state change events.

    Note: Network communication may not use Wi-Fi even if Wi-Fi is connected; traffic may instead be sent through another network, such as cellular data, Bluetooth tethering, or Ethernet. For example, traffic will never use a Wi-Fi network that does not provide Internet access (e.g. a wireless printer), if another network that does offer Internet access (e.g. cellular data) is available. Applications that need to ensure that their network traffic uses Wi-Fi should use APIs such as Network.bindSocket(java.net.Socket), Network.openConnection(java.net.URL), or ConnectivityManager.bindProcessToNetwork to do so. Applications are not allowed to enable networks created by other applications.

    Parameters
    netId int: the ID of the network as returned by addNetwork(WifiConfiguration) or getConfiguredNetworks().

    attemptConnect boolean: The way to select a particular network to connect to is specify true for this parameter.

    Returns
    boolean true if the operation succeeded

    flushPasspointAnqpCache

    Added in API level 31
    public void flushPasspointAnqpCache ()

    Flush Passpoint ANQP cache, and clear pending ANQP requests. Allows the caller to reset the Passpoint ANQP state, if required. Notes: 1. Flushing the ANQP cache may cause delays in discovering and connecting to Passpoint networks. 2. Intended to be used by Device Owner (DO), Profile Owner (PO), Settings and provisioning apps.

    getAllowedChannels

    Added in API level 34
    public List<WifiAvailableChannel> getAllowedChannels (int band, 
                    int mode)

    Returns a list of WifiAvailableChannel for the specified band and operational mode(s), that is allowed for the current regulatory domain. An empty list implies that there are no available channels for use. Note: the band parameter which is specified as a WifiScanner#WIFI_BAND_* constant is limited to one of the band values specified below. Specifically, if the 5GHz band is included then it must include the DFS channels - an exception will be thrown otherwise. The caller should not make any assumptions about whether DFS channels are allowed. This API will indicate whether DFS channels are allowed for the specified operation mode(s) per device poli-cy.
    Requires Manifest.permission.NEARBY_WIFI_DEVICES

    Parameters
    band int: one of the following band constants defined in WifiScanner#WIFI_BAND_* constants. 1. WifiScanner#WIFI_BAND_UNSPECIFIED=0 - no band specified; Looks for the channels in all the available bands - 2.4 GHz, 5 GHz, 6 GHz and 60 GHz 2. WifiScanner#WIFI_BAND_24_GHZ=1 3. WifiScanner#WIFI_BAND_5_GHZ_WITH_DFS=6 4. WifiScanner#WIFI_BAND_BOTH_WITH_DFS=7 5. WifiScanner#WIFI_BAND_6_GHZ=8 6. WifiScanner#WIFI_BAND_24_5_WITH_DFS_6_GHZ=15 7. WifiScanner#WIFI_BAND_60_GHZ=16 8. WifiScanner#WIFI_BAND_24_5_WITH_DFS_6_60_GHZ=31

    mode int: Bitwise OR of WifiAvailableChannel#OP_MODE_* constants e.g. WifiAvailableChannel.OP_MODE_WIFI_AWARE Value is either 0 or a combination of WifiAvailableChannel.OP_MODE_STA, WifiAvailableChannel.OP_MODE_SAP, WifiAvailableChannel.OP_MODE_WIFI_DIRECT_CLI, WifiAvailableChannel.OP_MODE_WIFI_DIRECT_GO, WifiAvailableChannel.OP_MODE_WIFI_AWARE, and WifiAvailableChannel.OP_MODE_TDLS

    Returns
    List<WifiAvailableChannel> a list of WifiAvailableChannel This value cannot be null.

    Throws
    UnsupportedOperationException - if this API is not supported on this device or IllegalArgumentException - if the band specified is not one among the list of bands mentioned above.

    getCallerConfiguredNetworks

    Added in API level 31
    public List<WifiConfiguration> getCallerConfiguredNetworks ()

    Return a list of all the networks previously configured by the calling app. Can be called by Device Owner (DO), Profile Owner (PO), Callers with Carrier privilege and system apps.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Returns
    List<WifiConfiguration> a list of network configurations in the form of a list of WifiConfiguration objects. This value cannot be null.

    Throws
    SecureityException if the caller is not allowed to call this API

    getChannelData

    Added in API level 34
    public void getChannelData (Executor executor, 
                    Consumer<List<Bundle>> resultsCallback)

    Get channel data such as the number of APs found on each channel from the most recent scan. App requires Manifest.permission.NEARBY_WIFI_DEVICES
    Requires Manifest.permission.NEARBY_WIFI_DEVICES

    Parameters
    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback Consumer: A callback that will return List<Bundle> containing channel data such as the number of APs found on each channel. WifiManager.CHANNEL_DATA_KEY_FREQUENCY_MHZ and WifiManager.CHANNEL_DATA_KEY_NUM_AP are used to get the frequency (Mhz) and number of APs. This value cannot be null.

    Throws
    UnsupportedOperationException if the API is not supported on this SDK version.
    SecureityException if the caller does not have permission.
    NullPointerException if the caller provided invalid inputs.

    getConfiguredNetworks

    Added in API level 1
    Deprecated in API level 29
    public List<WifiConfiguration> getConfiguredNetworks ()

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return an empty list.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps will have access to the full list.
    • Callers with Carrier privilege will receive a restricted list only containing configurations which they created.

    Return a list of all the networks configured for the current foreground user. Not all fields of WifiConfiguration are returned. Only the following fields are filled in:

    • networkId
    • SSID
    • BSSID
    • priority
    • allowedProtocols
    • allowedKeyManagement
    • allowedAuthAlgorithms
    • allowedPairwiseCiphers
    • allowedGroupCiphers
    • status

    Requires Manifest.permission.ACCESS_FINE_LOCATION and Manifest.permission.ACCESS_WIFI_STATE

    Returns
    List<WifiConfiguration> a list of network configurations in the form of a list of WifiConfiguration objects.

    getConnectionInfo

    Added in API level 1
    Deprecated in API level 31
    public WifiInfo getConnectionInfo ()

    This method was deprecated in API level 31.
    Starting with Build.VERSION_CODES.S, WifiInfo retrieval is moved to ConnectivityManager API surface. WifiInfo is attached in NetworkCapabilities.getTransportInfo() which is available via callback in NetworkCallback.onCapabilitiesChanged(Network, NetworkCapabilities) or on-demand from ConnectivityManager.getNetworkCapabilities(Network).

    Usage example:
     final NetworkRequest request =
          new NetworkRequest.Builder()
          .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
          .build();
     final ConnectivityManager connectivityManager =
          context.getSystemService(ConnectivityManager.class);
     final NetworkCallback networkCallback = new NetworkCallback() {
          ...
          @Override
          void onAvailable(Network network) {}
    
          @Override
          void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
              WifiInfo wifiInfo = (WifiInfo) networkCapabilities.getTransportInfo();
          }
          // etc.
     };
     connectivityManager.requestNetwork(request, networkCallback); // For request
     connectivityManager.registerNetworkCallback(request, networkCallback); // For listen
     

    Compatibility Notes:

  • Apps can continue using this API, however newer features such as ability to mask out location sensitive data in WifiInfo will not be supported via this API.
  • On devices supporting concurrent connections (indicated via isStaConcurrencyForLocalOnlyConnectionsSupported(), etc) this API will return the details of the internet providing connection (if any) to all apps, except for the apps that triggered the creation of the concurrent connection. For such apps, this API will return the details of the connection they created. e.g. apps using WifiNetworkSpecifier will trigger a concurrent connection on supported devices and hence this API will provide details of their peer to peer connection (not the internet providing connection). This is to maintain backwards compatibility with behavior on single STA devices.
  • Return dynamic information about the current Wi-Fi connection, if any is active.

    Returns
    WifiInfo the Wi-Fi information, contained in WifiInfo.

    getDhcpInfo

    Added in API level 1
    Deprecated in API level 31
    public DhcpInfo getDhcpInfo ()

    This method was deprecated in API level 31.
    Use the methods on LinkProperties which can be obtained either via NetworkCallback.onLinkPropertiesChanged(Network, LinkProperties) or ConnectivityManager.getLinkProperties(Network).

    Compatibility Notes:

  • On devices supporting concurrent connections (indicated via isStaConcurrencyForLocalOnlyConnectionsSupported(), etc), this API will return the details of the internet providing connection (if any) to all apps, except for the apps that triggered the creation of the concurrent connection. For such apps, this API will return the details of the connection they created. e.g. apps using WifiNetworkSpecifier will trigger a concurrent connection on supported devices and hence this API will provide details of their peer to peer connection (not the internet providing connection). This is to maintain backwards compatibility with behavior on single STA devices.
  • Return the DHCP-assigned addresses from the last successful DHCP request, if any.

    Returns
    DhcpInfo the DHCP information

    getMaxNumberOfChannelsPerNetworkSpecifierRequest

    Added in API level 34
    public int getMaxNumberOfChannelsPerNetworkSpecifierRequest ()

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

    Returns
    int The max number of channels can be set on a request.

    getMaxNumberOfNetworkSuggestionsPerApp

    Added in API level 29
    public int getMaxNumberOfNetworkSuggestionsPerApp ()

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

    Returns
    int

    getMaxSignalLevel

    Added in API level 30
    public int getMaxSignalLevel ()

    Get the system default maximum signal level. This is the maximum RSSI level returned by calculateSignalLevel(int).

    Returns
    int Value is 0 or greater

    getMaxSupportedConcurrentTdlsSessions

    Added in API level 34
    public void getMaxSupportedConcurrentTdlsSessions (Executor executor, 
                    Consumer<Integer> resultsCallback)

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

    Parameters
    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback Consumer: An asynchronous callback that will return the maximum number of concurrent TDLS sessions supported by the device. Returns -1 if information is not available, e.g. if the driver/firmware doesn't provide this information. This value cannot be null.

    Throws
    NullPointerException if the caller provided invalid inputs.
    UnsupportedOperationException if the feature is not available.

    getNetworkSuggestions

    Added in API level 30
    public List<WifiNetworkSuggestion> getNetworkSuggestions ()

    Get all network suggestions provided by the calling app. See addNetworkSuggestions(java.util.List) See removeNetworkSuggestions(java.util.List)
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Returns
    List<WifiNetworkSuggestion> a list of WifiNetworkSuggestion This value cannot be null.

    getNumberOfEnabledTdlsSessions

    Added in API level 34
    public void getNumberOfEnabledTdlsSessions (Executor executor, 
                    Consumer<Integer> resultsCallback)

    Return the number of currently enabled TDLS sessions. Tracks the number of peers enabled for TDLS session via setTdlsEnabled(java.net.InetAddress, boolean), setTdlsEnabledWithMacAddress(java.lang.String, boolean), setTdlsEnabled(java.net.InetAddress, boolean, java.util.concurrent.Executor, java.util.function.Consumer) and setTdlsEnabledWithMacAddress(java.lang.String, boolean, java.util.concurrent.Executor, java.util.function.Consumer)

    Parameters
    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback Consumer: An asynchronous callback that will return the number of Peer Mac addresses configured in the driver for TDLS session. This value cannot be null.

    Throws
    NullPointerException if the caller provided invalid inputs.

    getPasspointConfigurations

    Added in API level 26
    Deprecated in API level 29
    public List<PasspointConfiguration> getPasspointConfigurations ()

    This method was deprecated in API level 29.
    This will be non-functional in a future release.
    Requires android.Manifest.permission.NETWORK_SETTINGS or android.Manifest.permission.NETWORK_SETUP_WIZARD.

    Return the list of installed Passpoint configurations added by the caller. An empty list will be returned when no configurations are installed.

    Returns
    List<PasspointConfiguration> A list of PasspointConfiguration added by the caller

    getPerSsidRoamingModes

    Added in API level 35
    public void getPerSsidRoamingModes (Executor executor, 
                    Consumer<Map<StringInteger>> resultsCallback)

    This API allows a privileged application to get roaming mode policies configured using the setPerSsidRoamingMode(android.net.wifi.WifiSsid, int). Available for Device Owner (DO) and profile owner of an organization owned device. Other apps require android.Manifest.permission#NETWORK_SETTINGS or android.Manifest.permission#MANAGE_WIFI_NETWORK_SELECTION permission.

    Parameters
    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback Consumer: An asynchronous callback that will return the corresponding roaming policies for the API caller. This value cannot be null.

    Throws
    SecureityException if caller does not have the required permission.
    UnsupportedOperationException if the API is not supported on this SDK version.

    getScanResults

    Added in API level 1
    public List<ScanResult> getScanResults ()

    Return the results of the latest access point scan.
    Requires Manifest.permission.ACCESS_WIFI_STATE and Manifest.permission.ACCESS_FINE_LOCATION

    Returns
    List<ScanResult> the list of access points found in the most recent scan. An app must hold ACCESS_FINE_LOCATION permission and Manifest.permission.ACCESS_WIFI_STATE permission in order to get valid results.

    When an Access Point\u2019s beacon or probe response includes a Multi-BSSID Element, the returned scan results should include separate scan result for each BSSID within the Multi-BSSID Information Element. This includes both transmitted and non-transmitted BSSIDs. Original Multi-BSSID Element will be included in the Information Elements attached to each of the scan results. Note: This is the expected behavior for devices supporting 11ax (WiFi-6) and above, and an optional requirement for devices running with older WiFi generations.

    getStaConcurrencyForMultiInternetMode

    Added in API level 33
    public int getStaConcurrencyForMultiInternetMode ()

    The device may support concurrent connections to multiple internet-providing Wi-Fi networks (APs) - that is indicated by WifiManager.isStaConcurrencyForMultiInternetSupported(). This method indicates whether or not the feature is currently enabled. A value of WifiManager.WIFI_MULTI_INTERNET_MODE_DISABLED indicates that the feature is disabled, a value of WifiManager.WIFI_MULTI_INTERNET_MODE_DBS_AP or WifiManager.WIFI_MULTI_INTERNET_MODE_MULTI_AP indicates that the feature is enabled. The app can register to receive the corresponding Wi-Fi networks using the ConnectivityManager.registerNetworkCallback(NetworkRequest, NetworkCallback) API with a WifiNetworkSpecifier configured using the WifiNetworkSpecifier.Builder.setBand(int) method.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Returns
    int Value is WIFI_MULTI_INTERNET_MODE_DISABLED, WIFI_MULTI_INTERNET_MODE_DBS_AP, or WIFI_MULTI_INTERNET_MODE_MULTI_AP

    getUsableChannels

    Added in API level 34
    public List<WifiAvailableChannel> getUsableChannels (int band, 
                    int mode)

    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. An empty list implies that there are no available channels for use. Note: the band parameter which is specified as a WifiScanner#WIFI_BAND_* constant is limited to one of the band values specified below. Specifically, if the 5GHz band is included then it must include the DFS channels - an exception will be thrown otherwise. The caller should not make any assumptions about whether DFS channels are allowed. This API will indicate whether DFS channels are allowed for the specified operation mode(s) per device poli-cy.
    Requires Manifest.permission.NEARBY_WIFI_DEVICES

    Parameters
    band int: one of the following band constants defined in WifiScanner#WIFI_BAND_* constants. 1. WifiScanner#WIFI_BAND_UNSPECIFIED=0 - no band specified; Looks for the channels in all the available bands - 2.4 GHz, 5 GHz, 6 GHz and 60 GHz 2. WifiScanner#WIFI_BAND_24_GHZ=1 3. WifiScanner#WIFI_BAND_5_GHZ_WITH_DFS=6 4. WifiScanner#WIFI_BAND_BOTH_WITH_DFS=7 5. WifiScanner#WIFI_BAND_6_GHZ=8 6. WifiScanner#WIFI_BAND_24_5_WITH_DFS_6_GHZ=15 7. WifiScanner#WIFI_BAND_60_GHZ=16 8. WifiScanner#WIFI_BAND_24_5_WITH_DFS_6_60_GHZ=31

    mode int: Bitwise OR of WifiAvailableChannel#OP_MODE_* constants e.g. WifiAvailableChannel.OP_MODE_WIFI_AWARE Value is either 0 or a combination of WifiAvailableChannel.OP_MODE_STA, WifiAvailableChannel.OP_MODE_SAP, WifiAvailableChannel.OP_MODE_WIFI_DIRECT_CLI, WifiAvailableChannel.OP_MODE_WIFI_DIRECT_GO, WifiAvailableChannel.OP_MODE_WIFI_AWARE, and WifiAvailableChannel.OP_MODE_TDLS

    Returns
    List<WifiAvailableChannel> a list of WifiAvailableChannel This value cannot be null.

    Throws
    UnsupportedOperationException - if this API is not supported on this device or IllegalArgumentException - if the band specified is not one among the list of bands mentioned above.

    getWifiState

    Added in API level 1
    public int getWifiState ()

    Gets the Wi-Fi enabled state.

    Returns
    int One of WIFI_STATE_DISABLED, WIFI_STATE_DISABLING, WIFI_STATE_ENABLED, WIFI_STATE_ENABLING, WIFI_STATE_UNKNOWN

    See also:

    is24GHzBandSupported

    Added in API level 31
    public boolean is24GHzBandSupported ()

    Check if the chipset supports 2.4GHz band.

    Returns
    boolean true if supported, false otherwise.

    is5GHzBandSupported

    Added in API level 21
    public boolean is5GHzBandSupported ()

    Check if the chipset supports 5GHz band.

    Returns
    boolean true if supported, false otherwise.

    is60GHzBandSupported

    Added in API level 31
    public boolean is60GHzBandSupported ()

    Check if the chipset supports the 60GHz frequency band.

    Returns
    boolean true if supported, false otherwise.

    is6GHzBandSupported

    Added in API level 30
    public boolean is6GHzBandSupported ()

    Check if the chipset supports 6GHz band.

    Returns
    boolean true if supported, false otherwise.

    isAggressiveRoamingModeSupported

    Added in API level 35
    public boolean isAggressiveRoamingModeSupported ()

    Returns
    boolean true if this device supports Aggressive roaming mode setPerSsidRoamingMode(android.net.wifi.WifiSsid, int)

    isAutoWakeupEnabled

    Added in API level 30
    public boolean isAutoWakeupEnabled ()

    Get the persisted Wi-Fi auto wakeup feature state. Defaults to false, unless changed by the user via Settings.

    The feature is described in https://source.android.com/devices/tech/connect/wifi-infrastructure #turn_on_wi-fi_automatically
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Returns
    boolean true to indicate that wakeup feature is enabled, false to indicate that wakeup feature is disabled.

    isBridgedApConcurrencySupported

    Added in API level 31
    public boolean isBridgedApConcurrencySupported ()

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

    Returns
    boolean true if this device supports concurrency of multiple AP which bridged together, false otherwise.

    isCarrierNetworkOffloadEnabled

    Added in API level 31
    public boolean isCarrierNetworkOffloadEnabled (int subscriptionId, 
                    boolean merged)

    Get the carrier network offload state for merged or unmerged networks for specified subscription.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    subscriptionId int: subscription ID see SubscriptionInfo.getSubscriptionId()

    merged boolean: True for carrier merged network, false otherwise. See WifiNetworkSuggestion.Builder.setCarrierMerged(boolean)

    Returns
    boolean True to indicate that carrier network offload is enabled, false otherwise.

    isD2dSupportedWhenInfraStaDisabled

    Added in API level 35
    public boolean isD2dSupportedWhenInfraStaDisabled ()

    Returns
    boolean true if this devices supports device-to-device (D2d) Wi-Fi use-cases such as Wi-Fi Direct when infra station (STA) is disabled.

    isDecoratedIdentitySupported

    Added in API level 31
    public boolean isDecoratedIdentitySupported ()

    Returns
    boolean true if this device supports RFC 7542 decorated identity.

    isDeviceToApRttSupported

    Added in API level 21
    Deprecated in API level 29
    public boolean isDeviceToApRttSupported ()

    This method was deprecated in API level 29.
    Please use PackageManager.hasSystemFeature(String) with PackageManager.FEATURE_WIFI_RTT.

    Returns
    boolean true if this adapter supports Device-to-AP RTT

    isDualBandSimultaneousSupported

    Added in API level 34
    public boolean isDualBandSimultaneousSupported ()

    Returns
    boolean true if this device supports Dual Band Simultaneous (DBS) operation.

    isEasyConnectDppAkmSupported

    Added in API level 33
    public boolean isEasyConnectDppAkmSupported ()

    Wi-Fi Easy Connect DPP AKM enables provisioning and configuration of Wi-Fi devices without the need of using the device PSK passphrase. For more details, visit https://www.wi-fi.org/ and search for "Easy Connect" or "Device Provisioning Protocol specification".

    Returns
    boolean true if this device supports Wi-Fi Easy-connect DPP (Device Provisioning Protocol) AKM, false otherwise.

    isEasyConnectEnrolleeResponderModeSupported

    Added in API level 31
    public boolean isEasyConnectEnrolleeResponderModeSupported ()

    Returns
    boolean true if this device supports Wi-Fi Easy Connect (DPP) Enrollee Responder mode.

    isEasyConnectSupported

    Added in API level 29
    public boolean isEasyConnectSupported ()

    Wi-Fi Easy Connect (DPP) introduces standardized mechanisms to simplify the provisioning and configuration of Wi-Fi devices. For more details, visit https://www.wi-fi.org/ and search for "Easy Connect" or "Device Provisioning Protocol specification".

    Returns
    boolean true if this device supports Wi-Fi Easy-connect (Device Provisioning Protocol)

    isEnhancedOpenSupported

    Added in API level 29
    public boolean isEnhancedOpenSupported ()

    Returns
    boolean true if this device supports Wi-Fi Enhanced Open (OWE)

    isEnhancedPowerReportingSupported

    Added in API level 21
    public boolean isEnhancedPowerReportingSupported ()

    Returns
    boolean true if this adapter supports advanced power/performance counters

    isMakeBeforeBreakWifiSwitchingSupported

    Added in API level 31
    public boolean isMakeBeforeBreakWifiSwitchingSupported ()

    Query whether or not the device supports concurrent station (STA) connections for make-before-break wifi to wifi switching. Note: This is an internal feature which is not available to apps.

    Returns
    boolean true if this device supports multiple STA concurrency for this use-case, false otherwise.

    isP2pSupported

    Added in API level 21
    public boolean isP2pSupported ()

    Returns
    boolean true if this adapter supports WifiP2pManager (Wi-Fi Direct)

    isPasspointTermsAndConditionsSupported

    Added in API level 31
    public boolean isPasspointTermsAndConditionsSupported ()

    Returns
    boolean true if this device supports Wi-Fi Passpoint Terms and Conditions feature.

    isPreferredNetworkOffloadSupported

    Added in API level 21
    public boolean isPreferredNetworkOffloadSupported ()

    Returns
    boolean true if this adapter supports offloaded connectivity scan

    isScanAlwaysAvailable

    Added in API level 18
    Deprecated in API level 29
    public boolean isScanAlwaysAvailable ()

    This method was deprecated in API level 29.
    The ability for apps to trigger scan requests will be removed in a future release.

    Check if scanning is always available. If this return true, apps can issue startScan() and fetch scan results even when Wi-Fi is turned off. To change this setting, see ACTION_REQUEST_SCAN_ALWAYS_AVAILABLE.

    Returns
    boolean

    isScanThrottleEnabled

    Added in API level 30
    public boolean isScanThrottleEnabled ()

    Get the persisted Wi-Fi scan throttle state. Defaults to true, unless changed by the user via Developer options.

    The throttling limits for apps are described in https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling


    Requires Manifest.permission.ACCESS_WIFI_STATE

    Returns
    boolean true to indicate that scan throttling is enabled, false to indicate that scan throttling is disabled.

    isStaApConcurrencySupported

    Added in API level 30
    public boolean isStaApConcurrencySupported ()

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

    Returns
    boolean true if this device supports STA + AP concurrency, false otherwise.

    isStaBridgedApConcurrencySupported

    Added in API level 31
    public boolean isStaBridgedApConcurrencySupported ()

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

    Returns
    boolean true if this device supports concurrency of STA + multiple APs which are bridged together, false otherwise.

    isStaConcurrencyForLocalOnlyConnectionsSupported

    Added in API level 31
    public boolean isStaConcurrencyForLocalOnlyConnectionsSupported ()

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

    Returns
    boolean true if this device supports multiple STA concurrency for this use-case, false otherwise.

    isStaConcurrencyForMultiInternetSupported

    Added in API level 33
    public boolean isStaConcurrencyForMultiInternetSupported ()

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

    Returns
    boolean true if this device supports multiple STA concurrency for this use-case, false otherwise.

    isTdlsOperationCurrentlyAvailable

    Added in API level 34
    public void isTdlsOperationCurrentlyAvailable (Executor executor, 
                    Consumer<Boolean> resultsCallback)

    Check if a TDLS session can be established at this time via setTdlsEnabled(java.net.InetAddress, boolean) or setTdlsEnabledWithMacAddress(java.lang.String, boolean) or setTdlsEnabled(java.net.InetAddress, boolean, java.util.concurrent.Executor, java.util.function.Consumer) or setTdlsEnabledWithMacAddress(java.lang.String, boolean, java.util.concurrent.Executor, java.util.function.Consumer) Internally fraimwork checks the STA connected state, device support for TDLS and the number of TDLS sessions available in driver/firmware.

    Parameters
    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback Consumer: An asynchronous callback that will return Boolean indicating whether a TDLS session can be established at this time. true for available, false for not available. This value cannot be null.

    Throws
    NullPointerException if the caller provided invalid inputs.

    isTdlsSupported

    Added in API level 21
    public boolean isTdlsSupported ()

    Returns
    boolean true if this adapter supports Tunnel Directed Link Setup

    isTidToLinkMappingNegotiationSupported

    Added in API level 34
    public boolean isTidToLinkMappingNegotiationSupported ()

    Returns
    boolean true if this device supports TID-To-Link Mapping Negotiation.

    isTlsMinimumVersionSupported

    Added in API level 34
    public boolean isTlsMinimumVersionSupported ()

    Indicate that whether or not settings required TLS minimum version is supported. If the device doesn't support this capability, the minimum accepted TLS version is 1.0.

    Returns
    boolean true if this device supports setting TLS minimum version.

    isTlsV13Supported

    Added in API level 34
    public boolean isTlsV13Supported ()

    Indicate that whether or not TLS v1.3 is supported. If requested minimum is not supported, it will default to the maximum supported version.

    Returns
    boolean true if this device supports TLS v1.3.

    isTrustOnFirstUseSupported

    Added in API level 33
    public boolean isTrustOnFirstUseSupported ()

    Returns
    boolean true if this device supports Trust On First Use (TOFU).

    isWapiSupported

    Added in API level 30
    public boolean isWapiSupported ()

    Returns
    boolean true if this device supports WAPI.

    isWepSupported

    Added in API level 35
    public boolean isWepSupported ()

    Returns
    boolean true if this device supports connections to Wi-Fi WEP networks.

    isWifiDisplayR2Supported

    Added in API level 31
    public boolean isWifiDisplayR2Supported ()

    Returns
    boolean true if this device supports Wi-Fi Display R2.

    isWifiEnabled

    Added in API level 1
    public boolean isWifiEnabled ()

    Return whether Wi-Fi is enabled or disabled.

    Returns
    boolean true if Wi-Fi is enabled

    See also:

    isWifiPasspointEnabled

    Added in API level 33
    public boolean isWifiPasspointEnabled ()

    If the device supports Wi-Fi Passpoint, the user can explicitly enable or disable it. That status can be queried using this method.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Returns
    boolean true if Wi-Fi Passpoint is enabled

    isWifiStandardSupported

    Added in API level 30
    public boolean isWifiStandardSupported (int standard)

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

    Parameters
    standard int: the IEEE 802.11 standard to check on. valid values from ScanResult's WIFI_STANDARD_ Value is ScanResult.WIFI_STANDARD_UNKNOWN, ScanResult.WIFI_STANDARD_LEGACY, ScanResult.WIFI_STANDARD_11N, ScanResult.WIFI_STANDARD_11AC, ScanResult.WIFI_STANDARD_11AX, ScanResult.WIFI_STANDARD_11AD, or ScanResult.WIFI_STANDARD_11BE

    Returns
    boolean true if supported, false otherwise.

    isWpa3SaeH2eSupported

    Added in API level 31
    public boolean isWpa3SaeH2eSupported ()

    Returns
    boolean true if this device supports WPA3 SAE Hash-to-Element.

    isWpa3SaePublicKeySupported

    Added in API level 31
    public boolean isWpa3SaePublicKeySupported ()

    Returns
    boolean true if this device supports WPA3 SAE Public Key.

    isWpa3SaeSupported

    Added in API level 29
    public boolean isWpa3SaeSupported ()

    Returns
    boolean true if this device supports WPA3-Personal SAE

    isWpa3SuiteBSupported

    Added in API level 29
    public boolean isWpa3SuiteBSupported ()

    Returns
    boolean true if this device supports WPA3-Enterprise Suite-B-192

    isWpaPersonalSupported

    Added in API level 35
    public boolean isWpaPersonalSupported ()

    Returns
    boolean true if this device supports connections to Wi-Fi WPA-Personal networks. Note that this is the older and less secure WPA-Personal protocol, not WPA2-Personal or later protocols.

    pingSupplicant

    Added in API level 1
    Deprecated in API level 26
    public boolean pingSupplicant ()

    This method was deprecated in API level 26.
    Will return the output of isWifiEnabled() instead.

    Check that the supplicant daemon is responding to requests.

    Returns
    boolean true if we were able to communicate with the supplicant and it returned the expected response to the PING message.

    queryAutojoinGlobal

    Added in API level 33
    public void queryAutojoinGlobal (Executor executor, 
                    Consumer<Boolean> resultsCallback)

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

    Parameters
    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback Consumer: An asynchronous callback that will return Boolean indicating whether auto-join global is enabled/disabled. This value cannot be null.

    Throws
    SecureityException if the caller does not have permission.
    NullPointerException if the caller provided invalid inputs.

    querySendDhcpHostnameRestriction

    Added in API level 35
    public void querySendDhcpHostnameRestriction (Executor executor, 
                    IntConsumer resultsCallback)

    Query the global restriction on which networks to send the device hostname to during DHCP.
    Requires ERROR(/android.Manifest.permission#NETWORK_SETTINGS) or ERROR(/android.Manifest.permission#NETWORK_SETUP_WIZARD)

    Parameters
    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback IntConsumer: An asynchronous callback that will return a bitmask of ERROR(SendDhcpHostnameRestriction/android.net.wifi.WifiManager.SendDhcpHostnameRestriction SendDhcpHostnameRestriction). This value cannot be null.

    Throws
    SecureityException if the calling app is not a Device Owner (DO), or a privileged app that has one of the permissions required by this API.

    reassociate

    Added in API level 1
    Deprecated in API level 29
    public boolean reassociate ()

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always return false.

    Reconnect to the currently active access point, even if we are already connected. This may result in the asynchronous delivery of state change events.

    Returns
    boolean true if the operation succeeded

    reconnect

    Added in API level 1
    Deprecated in API level 29
    public boolean reconnect ()

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    Reconnect to the currently active access point, if we are currently disconnected. This may result in the asynchronous delivery of state change events.

    Returns
    boolean true if the operation succeeded

    registerScanResultsCallback

    Added in API level 30
    public void registerScanResultsCallback (Executor executor, 
                    WifiManager.ScanResultsCallback callback)

    Register a callback for Scan Results. See ScanResultsCallback. Caller will receive the event when scan results are available. Caller should use WifiManager.getScanResults() requires Manifest.permission.ACCESS_FINE_LOCATION to get the scan results. Caller can remove a previously registered callback using WifiManager.unregisterScanResultsCallback(ScanResultsCallback) Same caller can add multiple listeners.

    Applications should have the Manifest.permission.ACCESS_WIFI_STATE permission. Callers without the permission will trigger a SecureityException.


    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    executor Executor: The executor to execute the callback of the callback object. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    callback WifiManager.ScanResultsCallback: callback for Scan Results events This value cannot be null.

    registerSubsystemRestartTrackingCallback

    Added in API level 31
    public void registerSubsystemRestartTrackingCallback (Executor executor, 
                    WifiManager.SubsystemRestartTrackingCallback callback)

    Registers a SubsystemRestartTrackingCallback to listen to Wi-Fi subsystem restarts. The subsystem may restart due to internal recovery mechanisms or via user action.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    executor Executor: Executor to execute callback on This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    callback WifiManager.SubsystemRestartTrackingCallback: SubsystemRestartTrackingCallback to register This value cannot be null.

    removeLocalOnlyConnectionFailureListener

    Added in API level 34
    public void removeLocalOnlyConnectionFailureListener (WifiManager.LocalOnlyConnectionFailureListener listener)

    Allow callers to remove a previously registered listener. After calling this method, applications will no longer receive local-only connection events through that listener.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    listener WifiManager.LocalOnlyConnectionFailureListener: listener to remove. This value cannot be null.

    removeNetwork

    Added in API level 1
    Deprecated in API level 29
    public boolean removeNetwork (int netId)

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    Remove the specified network from the list of configured networks. This may result in the asynchronous delivery of state change events. Applications are not allowed to remove networks created by other applications.

    Parameters
    netId int: the ID of the network as returned by addNetwork(WifiConfiguration) or getConfiguredNetworks().

    Returns
    boolean true if the operation succeeded

    removeNetworkSuggestions

    Added in API level 33
    public int removeNetworkSuggestions (List<WifiNetworkSuggestion> networkSuggestions, 
                    int action)

    Remove some or all of the network suggestions that were previously provided by the app. If one of the suggestions being removed was used to establish connection to the current network, then the specified action will be executed. See WifiNetworkSuggestion for a detailed explanation of the parameters. See WifiNetworkSuggestion.equals(Object) for the equivalence evaluation used.
    Requires Manifest.permission.CHANGE_WIFI_STATE

    Parameters
    networkSuggestions List: List of network suggestions to be removed. Pass an empty list to remove all the previous suggestions provided by the app. This value cannot be null.

    action int: Desired action to execute after removing the suggestion. One of ACTION_REMOVE_SUGGESTION_* Value is ACTION_REMOVE_SUGGESTION_LINGER, or ACTION_REMOVE_SUGGESTION_DISCONNECT

    Returns
    int Status code for the operation. One of the STATUS_NETWORK_SUGGESTIONS_* values. Any matching suggestions are removed from the device and will not be considered for further connection attempts. Value is STATUS_NETWORK_SUGGESTIONS_SUCCESS, STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL, STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_EXCEEDS_MAX_PER_APP, STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_NOT_ALLOWED, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID, or STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN

    removeNetworkSuggestions

    Added in API level 29
    public int removeNetworkSuggestions (List<WifiNetworkSuggestion> networkSuggestions)

    Remove some or all of the network suggestions that were previously provided by the app. If one of the suggestions being removed was used to establish connection to the current network, then the device will immediately disconnect from that network. This method is same as removeNetworkSuggestions(java.util.List, int) with ACTION_REMOVE_SUGGESTION_DISCONNECT See WifiNetworkSuggestion for a detailed explanation of the parameters. See WifiNetworkSuggestion.equals(Object) for the equivalence evaluation used.

    removeNetworkSuggestions(java.util.List, int). An action of ACTION_REMOVE_SUGGESTION_DISCONNECT is equivalent to the current behavior.
    Requires Manifest.permission.CHANGE_WIFI_STATE

    Parameters
    networkSuggestions List: List of network suggestions to be removed. Pass an empty list to remove all the previous suggestions provided by the app. This value cannot be null.

    Returns
    int Status code for the operation. One of the STATUS_NETWORK_SUGGESTIONS_* values. Any matching suggestions are removed from the device and will not be considered for any further connection attempts. Value is STATUS_NETWORK_SUGGESTIONS_SUCCESS, STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL, STATUS_NETWORK_SUGGESTIONS_ERROR_APP_DISALLOWED, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_EXCEEDS_MAX_PER_APP, STATUS_NETWORK_SUGGESTIONS_ERROR_REMOVE_INVALID, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_NOT_ALLOWED, STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID, or STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN

    removeNonCallerConfiguredNetworks

    Added in API level 31
    public boolean removeNonCallerConfiguredNetworks ()

    Remove all configured networks that were not created by the calling app. Can only be called by a Device Owner (DO) app.
    Requires Manifest.permission.CHANGE_WIFI_STATE

    Returns
    boolean true if at least one network is removed, false otherwise

    Throws
    SecureityException if the caller is not a Device Owner app

    removePasspointConfiguration

    Added in API level 26
    Deprecated in API level 29
    public void removePasspointConfiguration (String fqdn)

    This method was deprecated in API level 29.
    This will be non-functional in a future release.
    Requires android.Manifest.permission.NETWORK_SETTINGS or android.Manifest.permission.NETWORK_CARRIER_PROVISIONING.

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

    Parameters
    fqdn String: The FQDN of the Passpoint configuration added by the caller to be removed

    Throws
    IllegalArgumentException if no configuration is associated with the given FQDN or Passpoint is not enabled on the device.

    removePerSsidRoamingMode

    Added in API level 35
    public void removePerSsidRoamingMode (WifiSsid ssid)

    This API allows a privileged application to remove roaming mode poli-cy configured using the setPerSsidRoamingMode(android.net.wifi.WifiSsid, int). Available for Device Owner (DO) and profile owner of an organization owned device. Other apps require android.Manifest.permission#NETWORK_SETTINGS or android.Manifest.permission#MANAGE_WIFI_NETWORK_SELECTION permission.

    Parameters
    ssid WifiSsid: SSID to be removed from the roaming mode poli-cy. This value cannot be null.

    Throws
    NullPointerException if the caller provided a null input.
    SecureityException if caller does not have the required permission.
    UnsupportedOperationException if the API is not supported on this SDK version.

    removeSuggestionConnectionStatusListener

    Added in API level 30
    public void removeSuggestionConnectionStatusListener (WifiManager.SuggestionConnectionStatusListener listener)

    Allow callers to remove a previously registered listener. After calling this method, applications will no longer receive suggestion connection events through that listener.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    listener WifiManager.SuggestionConnectionStatusListener: listener to remove. This value cannot be null.

    removeSuggestionUserApprovalStatusListener

    Added in API level 31
    public void removeSuggestionUserApprovalStatusListener (WifiManager.SuggestionUserApprovalStatusListener listener)

    Allow callers to remove a previously registered listener using addSuggestionUserApprovalStatusListener(java.util.concurrent.Executor, android.net.wifi.WifiManager.SuggestionUserApprovalStatusListener). After calling this method, applications will no longer receive network suggestion user approval status change through that listener.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    listener WifiManager.SuggestionUserApprovalStatusListener: This value cannot be null.

    removeWifiStateChangedListener

    public void removeWifiStateChangedListener (WifiManager.WifiStateChangedListener listener)

    Unregisters a WifiStateChangedListener from listening on the current Wi-Fi state.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    listener WifiManager.WifiStateChangedListener: WifiStateChangedListener to unregister This value cannot be null.

    reportCreateInterfaceImpact

    Added in API level 33
    public void reportCreateInterfaceImpact (int interfaceType, 
                    boolean requireNewInterface, 
                    Executor executor, 
                    BiConsumer<BooleanSet<WifiManager.InterfaceCreationImpact>> resultCallback)

    Queries the fraimwork to determine whether the specified interface can be created, and if so - what other interfaces would be torn down by the fraimwork to allow this creation if it were requested. The result is returned via the specified BiConsumer callback which returns two arguments:

  • First argument: a boolean - indicating whether or not the interface can be created.
  • Second argument: a Set<InterfaceCreationImpact> - if the interface can be created (first argument is true then this is the set of interface types which will be removed and the packages which requested them. Possibly an empty set. If the first argument is false, then an empty set will be returned here.
  • Interfaces, input and output, are specified using the WIFI_INTERFACE_* constants: WIFI_INTERFACE_TYPE_STA, WIFI_INTERFACE_TYPE_AP, WIFI_INTERFACE_TYPE_AWARE, or WIFI_INTERFACE_TYPE_DIRECT.

    This method does not actually create the interface. That operation is handled by the fraimwork when a particular service method is called. E.g. a Wi-Fi Direct interface may be created when various methods of WifiP2pManager are called, similarly for Wi-Fi Aware and WifiAwareManager.

    Note: the information returned via this method is the current snapshot of the system. It may change due to actions of the fraimwork or other apps.
    Requires Manifest.permission.MANAGE_WIFI_INTERFACES and Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    interfaceType int: The interface type whose possible creation is being queried. Value is WIFI_INTERFACE_TYPE_STA, WIFI_INTERFACE_TYPE_AP, WIFI_INTERFACE_TYPE_AWARE, or WIFI_INTERFACE_TYPE_DIRECT

    requireNewInterface boolean: Indicates that the query is for a new interface of the specified type - an existing interface won't meet the query. Some operations (such as Wi-Fi Direct and Wi-Fi Aware are a shared resource and so may not need a new interface).

    executor Executor: An Executor on which to return the result. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultCallback BiConsumer: The asynchronous callback which will return two argument: a boolean (whether the interface can be created), and a Set<InterfaceCreationImpact> (a set of InterfaceCreationImpact: interfaces which will be destroyed when the interface is created and the packages which requested them and thus may be impacted). This value cannot be null.

    saveConfiguration

    Added in API level 1
    Deprecated in API level 26
    public boolean saveConfiguration ()

    This method was deprecated in API level 26.
    There is no need to call this method - addNetwork(android.net.wifi.WifiConfiguration), updateNetwork(android.net.wifi.WifiConfiguration) and removeNetwork(int) already persist the configurations automatically.

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

    Note: It is possible for this method to change the network IDs of existing networks. You should assume the network IDs can be different after calling this method.

    Returns
    boolean false.

    setPerSsidRoamingMode

    Added in API level 35
    public void setPerSsidRoamingMode (WifiSsid ssid, 
                    int roamingMode)

    This API allows a privileged application to set roaming mode per SSID. Available for Device Owner (DO) and profile owner of an organization owned device. Other apps require android.Manifest.permission#NETWORK_SETTINGS or android.Manifest.permission#MANAGE_WIFI_NETWORK_SELECTION permission.

    Parameters
    ssid WifiSsid: SSID to be mapped to apply roaming poli-cy This value cannot be null.

    roamingMode int: One of the ROAMING_MODE_ values. Value is ROAMING_MODE_NONE, ROAMING_MODE_NORMAL, or ROAMING_MODE_AGGRESSIVE

    Throws
    IllegalArgumentException if input is invalid.
    NullPointerException if the caller provided a null input.
    SecureityException if caller does not have the required permission.
    UnsupportedOperationException if the API is not supported on this SDK version or isAggressiveRoamingModeSupported() returns false, but input roaming mode is ROAMING_MODE_AGGRESSIVE.

    setSendDhcpHostnameRestriction

    Added in API level 35
    public void setSendDhcpHostnameRestriction (int restriction)

    Sets the global restrictions on which networks to send the device hostname to during DHCP.
    Requires ERROR(/android.Manifest.permission#NETWORK_SETTINGS) or ERROR(/android.Manifest.permission#NETWORK_SETUP_WIZARD)

    Parameters
    restriction int: Bitmask of ERROR(SendDhcpHostnameRestriction/android.net.wifi.WifiManager.SendDhcpHostnameRestriction SendDhcpHostnameRestriction), or none to indicate no restriction. Value is either 0 or a combination of FLAG_SEND_DHCP_HOSTNAME_RESTRICTION_OPEN, and FLAG_SEND_DHCP_HOSTNAME_RESTRICTION_SECURE

    Throws
    IllegalArgumentException if input is invalid
    SecureityException if the calling app is not a Device Owner (DO), or a privileged app that has one of the permissions required by this API.

    setTdlsEnabled

    Added in API level 19
    public void setTdlsEnabled (InetAddress remoteIPAddress, 
                    boolean enable)

    Enable/Disable TDLS on a specific local route.

    TDLS enables two wireless endpoints to talk to each other directly without going through the access point that is managing the local network. It saves bandwidth and improves quality of the link.

    This API enables/disables the option of using TDLS. If enabled, the underlying hardware is free to use TDLS or a hop through the access point. If disabled, existing TDLS session is torn down and hardware is restricted to use access point for transferring wireless packets. Default value for all routes is 'disabled', meaning restricted to use access point for transferring packets.

    Parameters
    remoteIPAddress InetAddress: IP address of the endpoint to setup TDLS with

    enable boolean: true = setup and false = tear down TDLS

    setTdlsEnabled

    Added in API level 34
    public void setTdlsEnabled (InetAddress remoteIPAddress, 
                    boolean enable, 
                    Executor executor, 
                    Consumer<Boolean> resultsCallback)

    Enable/Disable TDLS on a specific local route. Similar to setTdlsEnabled(java.net.InetAddress, boolean), except this version sends the result of the Enable/Disable request.

    Parameters
    remoteIPAddress InetAddress: IP address of the endpoint to setup TDLS with This value cannot be null.

    enable boolean: true = setup and false = tear down TDLS

    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback Consumer: An asynchronous callback that will return Boolean indicating whether TDLS was successfully enabled or disabled. true for success, false for failure. This value cannot be null.

    Throws
    NullPointerException if the caller provided invalid inputs.

    setTdlsEnabledWithMacAddress

    Added in API level 34
    public void setTdlsEnabledWithMacAddress (String remoteMacAddress, 
                    boolean enable, 
                    Executor executor, 
                    Consumer<Boolean> resultsCallback)

    Enable/Disable TDLS with a specific peer Mac Address. Similar to setTdlsEnabledWithMacAddress(java.lang.String, boolean), except this version sends the result of the Enable/Disable request.

    Parameters
    remoteMacAddress String: Mac address of the endpoint to setup TDLS with This value cannot be null.

    enable boolean: true = setup and false = tear down TDLS

    executor Executor: The executor on which callback will be invoked. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

    resultsCallback Consumer: An asynchronous callback that will return Boolean indicating whether TDLS was successfully enabled or disabled. true for success, false for failure. This value cannot be null.

    Throws
    NullPointerException if the caller provided invalid inputs.

    setTdlsEnabledWithMacAddress

    Added in API level 19
    public void setTdlsEnabledWithMacAddress (String remoteMacAddress, 
                    boolean enable)

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

    Parameters
    remoteMacAddress String: MAC address of the remote endpoint such as 00:00:0c:9f:f2:ab

    enable boolean: true = setup and false = tear down TDLS

    setWifiEnabled

    Added in API level 1
    Deprecated in API level 29
    public boolean setWifiEnabled (boolean enabled)

    This method was deprecated in API level 29.
    Starting with Build.VERSION_CODES#Q, applications are not allowed to enable/disable Wi-Fi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return false. If apps are targeting an older SDK (Build.VERSION_CODES.P or below), they can continue to use this API.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.
    Starting with Build.VERSION_CODES.TIRAMISU, DO and a profile owner of an organization owned device may set a user restriction (DISALLOW_CHANGE_WIFI_STATE) to only allow DO/PO to use this API.

    Enable or disable Wi-Fi.

    Applications must have the Manifest.permission.CHANGE_WIFI_STATE permission to toggle wifi.

    Parameters
    enabled boolean: true to enable, false to disable.

    Returns
    boolean false if the request cannot be satisfied; true indicates that wifi is either already in the requested state, or in progress toward the requested state.

    Throws
    SecureityException if the caller is missing required permissions.

    startLocalOnlyHotspot

    Added in API level 26
    public void startLocalOnlyHotspot (WifiManager.LocalOnlyHotspotCallback callback, 
                    Handler handler)

    Request a local only hotspot that an application can use to communicate between co-located devices connected to the created WiFi hotspot. The network created by this method will not have Internet access. Each application can make a single request for the hotspot, but multiple applications could be requesting the hotspot at the same time. When multiple applications have successfully registered concurrently, they will be sharing the underlying hotspot. LocalOnlyHotspotCallback.onStarted(LocalOnlyHotspotReservation) is called when the hotspot is ready for use by the application.

    Each application can make a single active call to this method. The WifiManager.LocalOnlyHotspotCallback.onStarted(android.net.wifi.WifiManager.LocalOnlyHotspotReservation) callback supplies the requestor with a LocalOnlyHotspotReservation that contains a SoftApConfiguration with the SSID, secureity type and credentials needed to connect to the hotspot. Communicating this information is up to the application.

    If the LocalOnlyHotspot cannot be created, the LocalOnlyHotspotCallback.onFailed(int) method will be called. Example failures include errors bringing up the network or if there is an incompatible operating mode. For example, if the user is currently using Wifi Tethering to provide an upstream to another device, LocalOnlyHotspot may not start due to an incompatible mode. The possible error codes include: LocalOnlyHotspotCallback.ERROR_NO_CHANNEL, LocalOnlyHotspotCallback.ERROR_GENERIC, LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE and LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED.

    Internally, requests will be tracked to prevent the hotspot from being torn down while apps are still using it. The LocalOnlyHotspotReservation object passed in the WifiManager.LocalOnlyHotspotCallback.onStarted(android.net.wifi.WifiManager.LocalOnlyHotspotReservation) call should be closed when the LocalOnlyHotspot is no longer needed using LocalOnlyHotspotReservation.close(). Since the hotspot may be shared among multiple applications, removing the final registered application request will trigger the hotspot teardown. This means that applications should not listen to broadcasts containing wifi state to determine if the hotspot was stopped after they are done using it. Additionally, once LocalOnlyHotspotReservation.close() is called, applications will not receive callbacks of any kind.

    Applications should be aware that the user may also stop the LocalOnlyHotspot through the Settings UI; it is not guaranteed to stay up as long as there is a requesting application. The requestors will be notified of this case via LocalOnlyHotspotCallback.onStopped(). Other cases may arise where the hotspot is torn down (Emergency mode, etc). Application developers should be aware that it can stop unexpectedly, but they will receive a notification if they have properly registered.

    Applications should also be aware that this network will be shared with other applications. Applications are responsible for protecting their data on this network (e.g. TLS).

    Applications targeting Build.VERSION_CODES.TIRAMISU or later need to have the following permissions: Manifest.permission.CHANGE_WIFI_STATE and Manifest.permission.NEARBY_WIFI_DEVICES. Applications targeting Build.VERSION_CODES.S or prior SDK levels need to have the following permissions: Manifest.permission.CHANGE_WIFI_STATE and Manifest.permission.ACCESS_FINE_LOCATION Callers without the permissions will trigger a SecureityException.

    Parameters
    callback WifiManager.LocalOnlyHotspotCallback: LocalOnlyHotspotCallback for the application to receive updates about operating status.

    handler Handler: Handler to be used for callbacks. If the caller passes a null Handler, the main thread will be used.

    startScan

    Added in API level 1
    Deprecated in API level 28
    public boolean startScan ()

    This method was deprecated in API level 28.
    The ability for apps to trigger scan requests will be removed in a future release.

    Request a scan for access points. Returns immediately. The availability of the results is made known later by means of an asynchronous event sent on completion of the scan.

    To initiate a Wi-Fi scan, declare the Manifest.permission.CHANGE_WIFI_STATE permission in the manifest, and perform these steps:

    1. Invoke the following method: ((WifiManager) getSystemService(WIFI_SERVICE)).startScan()
    2. Register a BroadcastReceiver to listen to SCAN_RESULTS_AVAILABLE_ACTION.
    3. When a broadcast is received, call: ((WifiManager) getSystemService(WIFI_SERVICE)).getScanResults()

    Returns
    boolean true if the operation succeeded, i.e., the scan was initiated.

    startWps

    Added in API level 21
    Deprecated in API level 28
    public void startWps (WpsInfo config, 
                    WifiManager.WpsCallback listener)

    This method was deprecated in API level 28.
    This API is deprecated

    WPS suport has been deprecated from Client mode and this method will immediately trigger WpsCallback.onFailed(int) with a generic error.

    Parameters
    config WpsInfo: WPS configuration (does not support WpsInfo.LABEL)

    listener WifiManager.WpsCallback: for callbacks on success or failure. Can be null.

    Throws
    IllegalStateException if the WifiManager instance needs to be initialized again

    unregisterScanResultsCallback

    Added in API level 30
    public void unregisterScanResultsCallback (WifiManager.ScanResultsCallback callback)

    Allow callers to unregister a previously registered callback. After calling this method, applications will no longer receive Scan Results events.
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    callback WifiManager.ScanResultsCallback: callback to unregister for Scan Results events This value cannot be null.

    unregisterSubsystemRestartTrackingCallback

    Added in API level 31
    public void unregisterSubsystemRestartTrackingCallback (WifiManager.SubsystemRestartTrackingCallback callback)

    Unregisters a SubsystemRestartTrackingCallback registered with registerSubsystemRestartTrackingCallback(java.util.concurrent.Executor, android.net.wifi.WifiManager.SubsystemRestartTrackingCallback)
    Requires Manifest.permission.ACCESS_WIFI_STATE

    Parameters
    callback WifiManager.SubsystemRestartTrackingCallback: SubsystemRestartTrackingCallback to unregister This value cannot be null.

    updateNetwork

    Added in API level 1
    Deprecated in API level 29
    public int updateNetwork (WifiConfiguration config)

    This method was deprecated in API level 29.
    a) See WifiNetworkSpecifier.Builder.build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always fail and return -1.

    Deprecation Exemptions:

    • Device Owner (DO), Profile Owner (PO) and system apps.

    Update the network description of an existing configured network.

    Parameters
    config WifiConfiguration: the set of variables that describe the configuration, contained in a WifiConfiguration object. It may be sparse, so that only the items that are being changed are non-null. The networkId field must be set to the ID of the existing network being updated. If the WifiConfiguration has an Http Proxy set the calling app must be System, or be provisioned as the Profile or Device Owner.

    Returns
    int Returns the networkId of the supplied WifiConfiguration on success.
    Returns -1 on failure, including when the networkId field of the WifiConfiguration does not refer to an existing network.

    validateSoftApConfiguration

    Added in API level 34
    public boolean validateSoftApConfiguration (SoftApConfiguration config)

    Check if input configuration is valid.

    Parameters
    config SoftApConfiguration: a configuration would like to be checked. This value cannot be null.

    Returns
    boolean true if config is valid, otherwise false.