# Print output for @column tags ?> WifiManager - Android SDK | Android Developers

Most visited

Recently visited

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

class WifiManager.WpsCallback

This class is deprecated. This is deprecated 

Constants

String ACTION_PICK_WIFI_NETWORK

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

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.

int ERROR_AUTHENTICATING

This constant is deprecated. 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 is deprecated. 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 is deprecated. This is no longer supported.

String EXTRA_SUPPLICANT_ERROR

This constant is deprecated. 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.

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.

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_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_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 is deprecated. This is no longer supported.

String SUPPLICANT_STATE_CHANGED_ACTION

This constant is deprecated. This is no longer supported.

String UNKNOWN_SSID

Indicates an invalid SSID.

int WIFI_MODE_FULL

This constant is deprecated. This API is non-functional and will have no impact.

int WIFI_MODE_FULL_HIGH_PERF

In this Wi-Fi lock mode, Wi-Fi will not go to power save.

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 is deprecated. This API is non-functional and will have no impact.

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 is deprecated. This is deprecated

int WPS_OVERLAP_ERROR

This constant is deprecated. This is deprecated

int WPS_TIMED_OUT

This constant is deprecated. This is deprecated

int WPS_TKIP_ONLY_PROHIBITED

This constant is deprecated. This is deprecated

int WPS_WEP_PROHIBITED

This constant is deprecated. This is deprecated

Public methods

int addNetwork(WifiConfiguration config)

This method is deprecated. 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.

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 is deprecated. 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 is deprecated. 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 is deprecated. This API is non-functional.

WifiManager.WifiLock createWifiLock(int lockType, String tag)

Creates a new WifiLock.

boolean disableNetwork(int netId)

This method is deprecated. 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 is deprecated. 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 is deprecated. 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<WifiConfiguration> getCallerConfiguredNetworks()

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

List<WifiConfiguration> getConfiguredNetworks()

This method is deprecated. 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 is deprecated. 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() {
      ...
      {@literal @}Override
      void onAvailable(Network network) {}

      {@literal @}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 is deprecated. 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 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.

    List<WifiNetworkSuggestion> getNetworkSuggestions()

    Get all network suggestions provided by the calling app.

    List<PasspointConfiguration> getPasspointConfigurations()

    This method is deprecated. This will be non-functional in a future release.

    List<ScanResult> getScanResults()

    Return the results of the latest access point scan.

    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 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 isDecoratedIdentitySupported()
    boolean isDeviceToApRttSupported()

    This method is deprecated. Please use PackageManager.hasSystemFeature(String) with PackageManager.FEATURE_WIFI_RTT.

    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 is deprecated. 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 isTdlsSupported()
    boolean isWapiSupported()
    boolean isWifiDisplayR2Supported()
    boolean isWifiEnabled()

    Return whether Wi-Fi is enabled or disabled.

    boolean isWifiStandardSupported(int standard)

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

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

    This method is deprecated. Will return the output of isWifiEnabled() instead.

    boolean reassociate()

    This method is deprecated. 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 is deprecated. 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.

    boolean removeNetwork(int netId)

    This method is deprecated. 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)

    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 is deprecated. This will be non-functional in a future release.

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

    boolean saveConfiguration()

    This method is deprecated. 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 setTdlsEnabled(InetAddress remoteIPAddress, boolean enable)

    Enable/Disable TDLS on a specific local route.

    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 is deprecated. 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.

    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 is deprecated. The ability for apps to trigger scan requests will be removed in a future release.

    void startWps(WpsInfo config, WifiManager.WpsCallback listener)

    This method is deprecated. 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 is deprecated. 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.

    Inherited methods

    Constants

    ACTION_PICK_WIFI_NETWORK

    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_REQUEST_SCAN_ALWAYS_AVAILABLE

    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

    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.

    See also:

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

    ACTION_WIFI_SCAN_AVAILABILITY_CHANGED

    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"

    ERROR_AUTHENTICATING

    public static final int ERROR_AUTHENTICATING

    This constant is deprecated.
    This is no longer supported.

    The error code if there was a problem authenticating.

    Constant Value: 1 (0x00000001)

    EXTRA_BSSID

    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

    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

    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

    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

    public static final String EXTRA_NEW_STATE

    This constant is deprecated.
    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

    public static final String EXTRA_PREVIOUS_WIFI_STATE

    The previous Wi-Fi state.

    See also:

    Constant Value: "previous_wifi_state"

    EXTRA_RESULTS_UPDATED

    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

    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

    public static final String EXTRA_SUPPLICANT_CONNECTED

    This constant is deprecated.
    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

    public static final String EXTRA_SUPPLICANT_ERROR

    This constant is deprecated.
    This is no longer supported.

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

    See also:

    Constant Value: "supplicantError"

    EXTRA_WIFI_INFO

    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

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

    See also:

    Constant Value: "wifi_state"

    NETWORK_IDS_CHANGED_ACTION

    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

    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"

    RSSI_CHANGED_ACTION

    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

    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_NETWORK_SUGGESTIONS_ERROR_ADD_DUPLICATE

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

    See also:

    Constant Value: 3 (0x00000003)

    STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_EXCEEDS_MAX_PER_APP

    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 framework will reject all suggestions provided by addNetworkSuggestions(java.util.List) if the total size exceeds the limit.

    See also:

    Constant Value: 4 (0x00000004)

    STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID

    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 framework 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

    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 framework 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

    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.

    See also:

    Constant Value: 2 (0x00000002)

    STATUS_NETWORK_SUGGESTIONS_ERROR_INTERNAL

    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

    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 framework won't remove any suggestions if one or more of suggestions provided by removeNetworkSuggestions(java.util.List) does not exist in database.

    See also:

    Constant Value: 5 (0x00000005)

    STATUS_NETWORK_SUGGESTIONS_SUCCESS

    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

    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.

    See also:

    Constant Value: 4 (0x00000004)

    STATUS_SUGGESTION_APPROVAL_APPROVED_BY_USER

    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

    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

    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

    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

    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

    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

    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

    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

    public static final String SUPPLICANT_CONNECTION_CHANGE_ACTION

    This constant is deprecated.
    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.

    See also:

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

    SUPPLICANT_STATE_CHANGED_ACTION

    public static final String SUPPLICANT_STATE_CHANGED_ACTION

    This constant is deprecated.
    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.

    See also:

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

    UNKNOWN_SSID

    public static final String UNKNOWN_SSID

    Indicates an invalid SSID.

    Constant Value: ""

    WIFI_MODE_FULL

    public static final int WIFI_MODE_FULL

    This constant is deprecated.
    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

    public static final int WIFI_MODE_FULL_HIGH_PERF

    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

    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

    public static final int WIFI_MODE_SCAN_ONLY

    This constant is deprecated.
    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_STATE_CHANGED_ACTION

    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.

    See also:

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

    WIFI_STATE_DISABLED

    public static final int WIFI_STATE_DISABLED

    Wi-Fi is disabled.

    See also:

    Constant Value: 1 (0x00000001)

    WIFI_STATE_DISABLING

    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.

    See also:

    Constant Value: 0 (0x00000000)

    WIFI_STATE_ENABLED

    public static final int WIFI_STATE_ENABLED

    Wi-Fi is enabled.

    See also:

    Constant Value: 3 (0x00000003)

    WIFI_STATE_ENABLING

    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.

    See also:

    Constant Value: 2 (0x00000002)

    WIFI_STATE_UNKNOWN

    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.

    See also:

    Constant Value: 4 (0x00000004)

    WPS_AUTH_FAILURE

    public static final int WPS_AUTH_FAILURE

    This constant is deprecated.
    This is deprecated

    Authentication failure on WPS

    Constant Value: 6 (0x00000006)

    WPS_OVERLAP_ERROR

    public static final int WPS_OVERLAP_ERROR

    This constant is deprecated.
    This is deprecated

    WPS overlap detected

    Constant Value: 3 (0x00000003)

    WPS_TIMED_OUT

    public static final int WPS_TIMED_OUT

    This constant is deprecated.
    This is deprecated

    WPS timed out

    Constant Value: 7 (0x00000007)

    WPS_TKIP_ONLY_PROHIBITED

    public static final int WPS_TKIP_ONLY_PROHIBITED

    This constant is deprecated.
    This is deprecated

    TKIP only prohibited

    Constant Value: 5 (0x00000005)

    WPS_WEP_PROHIBITED

    public static final int WPS_WEP_PROHIBITED

    This constant is deprecated.
    This is deprecated

    WEP on WPS is prohibited

    Constant Value: 4 (0x00000004)

    Public methods

    addNetwork

    public int addNetwork (WifiConfiguration config)

    This method is deprecated.
    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

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


    Requires android.Manifest.permission.NETWORK_SETTINGS or android.Manifest.permission.NETWORK_STACK or android.Manifest.permission.NETWORK_SETUP_WIZARD or android.Manifest.permission.NETWORK_MANAGED_PROVISIONING

    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.

    Throws
    java.lang.SecurityException SecurityException} 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.
    java.lang.IllegalArgumentException IllegalArgumentException} if the input configuration is null.

    addNetworkSuggestions

    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.

  • 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, or STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID

    Throws
    java.lang.SecurityException SecurityException} if the caller is missing required permissions.

    See also:

    addOrUpdatePasspointConfiguration

    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

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


    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(). To dispatch events through a shared thread pool, you can use AsyncTask#THREAD_POOL_EXECUTOR.

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

    addSuggestionUserApprovalStatusListener

    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(). To dispatch events through a shared thread pool, you can use AsyncTask#THREAD_POOL_EXECUTOR.

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

    calculateSignalLevel

    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

    public static int calculateSignalLevel (int rssi, 
                    int numLevels)

    This method is deprecated.
    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

    public void cancelWps (WifiManager.WpsCallback listener)

    This method is deprecated.
    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

    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

    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.

    See also:

    createWifiLock

    public WifiManager.WifiLock createWifiLock (String tag)

    This method is deprecated.
    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.

    See also:

    createWifiLock

    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.

    See also:

    disableNetwork

    public boolean disableNetwork (int netId)

    This method is deprecated.
    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

    public boolean disconnect ()

    This method is deprecated.
    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

    public boolean enableNetwork (int netId, 
                    boolean attemptConnect)

    This method is deprecated.
    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

    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.
    Requires android.Manifest.permission.NETWORK_SETTINGS or android.Manifest.permission.NETWORK_MANAGED_PROVISIONING or android.Manifest.permission.NETWORK_CARRIER_PROVISIONING

    getCallerConfiguredNetworks

    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
    java.lang.SecurityException} if the caller is allowed to call this API

    getConfiguredNetworks

    public List<WifiConfiguration> getConfiguredNetworks ()

    This method is deprecated.
    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

    public WifiInfo getConnectionInfo ()

    This method is deprecated.
    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() {
          ...
          {@literal @}Override
          void onAvailable(Network network) {}
    
          {@literal @}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

    public DhcpInfo getDhcpInfo ()

    This method is deprecated.
    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

    getMaxNumberOfNetworkSuggestionsPerApp

    public int getMaxNumberOfNetworkSuggestionsPerApp ()

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

    Returns
    int

    See also:

    getMaxSignalLevel

    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

    getNetworkSuggestions

    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.

    getPasspointConfigurations

    public List<PasspointConfiguration> getPasspointConfigurations ()

    This method is deprecated.
    This will be non-functional in a future release.

    Return the list of installed Passpoint configurations added by the caller. An empty list will be returned when no configurations are installed.
    Requires android.Manifest.permission.NETWORK_SETTINGS or android.Manifest.permission.NETWORK_SETUP_WIZARD

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

    getScanResults

    public List<ScanResult> getScanResults ()

    Return the results of the latest access point scan.

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

    getWifiState

    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

    public boolean is24GHzBandSupported ()

    Check if the chipset supports 2.4GHz band.

    Returns
    boolean true if supported, false otherwise.

    is5GHzBandSupported

    public boolean is5GHzBandSupported ()

    Check if the chipset supports 5GHz band.

    Returns
    boolean true if supported, false otherwise.

    is60GHzBandSupported

    public boolean is60GHzBandSupported ()

    Check if the chipset supports the 60GHz frequency band.

    Returns
    boolean true if supported, false otherwise.

    is6GHzBandSupported

    public boolean is6GHzBandSupported ()

    Check if the chipset supports 6GHz band.

    Returns
    boolean true if supported, false otherwise.

    isAutoWakeupEnabled

    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

    public boolean isBridgedApConcurrencySupported ()

    Query whether or not the device supports multiple Access point (AP) which are bridged together. See SoftApConfiguration.Builder#setBands(int[]) or SoftApConfiguration.Builder#setChannels(android.util.SparseIntArray) to configure bridged AP when the bridged AP supported.

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

    isCarrierNetworkOffloadEnabled

    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.

    isDecoratedIdentitySupported

    public boolean isDecoratedIdentitySupported ()

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

    isDeviceToApRttSupported

    public boolean isDeviceToApRttSupported ()

    This method is deprecated.
    Please use PackageManager.hasSystemFeature(String) with PackageManager.FEATURE_WIFI_RTT.

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

    isEasyConnectEnrolleeResponderModeSupported

    public boolean isEasyConnectEnrolleeResponderModeSupported ()

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

    isEasyConnectSupported

    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

    public boolean isEnhancedOpenSupported ()

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

    isEnhancedPowerReportingSupported

    public boolean isEnhancedPowerReportingSupported ()

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

    isMakeBeforeBreakWifiSwitchingSupported

    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

    public boolean isP2pSupported ()

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

    isPasspointTermsAndConditionsSupported

    public boolean isPasspointTermsAndConditionsSupported ()

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

    isPreferredNetworkOffloadSupported

    public boolean isPreferredNetworkOffloadSupported ()

    Returns
    boolean true if this adapter supports offloaded connectivity scan

    isScanAlwaysAvailable

    public boolean isScanAlwaysAvailable ()

    This method is deprecated.
    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

    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

    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

    public boolean isStaBridgedApConcurrencySupported ()

    Query whether or not the device supports concurrency of Station (STA) + multiple access points (AP) (where the APs bridged together). See SoftApConfiguration.Builder#setBands(int[]) or SoftApConfiguration.Builder#setChannels(android.util.SparseIntArray) to configure bridged AP when the bridged AP supported.

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

    isStaConcurrencyForLocalOnlyConnectionsSupported

    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.

    isTdlsSupported

    public boolean isTdlsSupported ()

    Returns
    boolean true if this adapter supports Tunnel Directed Link Setup

    isWapiSupported

    public boolean isWapiSupported ()

    Returns
    boolean true if this device supports WAPI.

    isWifiDisplayR2Supported

    public boolean isWifiDisplayR2Supported ()

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

    isWifiEnabled

    public boolean isWifiEnabled ()

    Return whether Wi-Fi is enabled or disabled.

    Returns
    boolean true if Wi-Fi is enabled

    See also:

    isWifiStandardSupported

    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, or ScanResult.WIFI_STANDARD_11AD

    Returns
    boolean true if supported, false otherwise.

    isWpa3SaeH2eSupported

    public boolean isWpa3SaeH2eSupported ()

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

    isWpa3SaePublicKeySupported

    public boolean isWpa3SaePublicKeySupported ()

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

    isWpa3SaeSupported

    public boolean isWpa3SaeSupported ()

    Returns
    boolean true if this device supports WPA3-Personal SAE

    isWpa3SuiteBSupported

    public boolean isWpa3SuiteBSupported ()

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

    pingSupplicant

    public boolean pingSupplicant ()

    This method is deprecated.
    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.

    reassociate

    public boolean reassociate ()

    This method is deprecated.
    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

    public boolean reconnect ()

    This method is deprecated.
    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

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


    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(). To dispatch events through a shared thread pool, you can use AsyncTask#THREAD_POOL_EXECUTOR.

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

    registerSubsystemRestartTrackingCallback

    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(). To dispatch events through a shared thread pool, you can use AsyncTask#THREAD_POOL_EXECUTOR.

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

    See also:

    removeNetwork

    public boolean removeNetwork (int netId)

    This method is deprecated.
    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

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

    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, or STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_INVALID

    removeNonCallerConfiguredNetworks

    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
    java.lang.SecurityException} if the caller is not a Device Owner app

    removePasspointConfiguration

    public void removePasspointConfiguration (String fqdn)

    This method is deprecated.
    This will be non-functional in a future release.

    Remove the Passpoint configuration identified by its FQDN (Fully Qualified Domain Name) added by the caller.
    Requires android.Manifest.permission.NETWORK_SETTINGS or android.Manifest.permission.NETWORK_CARRIER_PROVISIONING

    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.

    removeSuggestionConnectionStatusListener

    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

    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.

    saveConfiguration

    public boolean saveConfiguration ()

    This method is deprecated.
    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.

    setTdlsEnabled

    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

    setTdlsEnabledWithMacAddress

    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

    public boolean setWifiEnabled (boolean enabled)

    This method is deprecated.
    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.

    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
    java.lang.SecurityException} if the caller is missing required permissions.

    startLocalOnlyHotspot

    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, security 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 will 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 need to have the following permissions to start LocalOnlyHotspot: Manifest.permission.CHANGE_WIFI_STATE and ACCESS_FINE_LOCATION. Callers without the permissions will trigger a SecurityException.


    Requires Manifest.permission.CHANGE_WIFI_STATE and Manifest.permission.ACCESS_FINE_LOCATION

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

    startScan

    public boolean startScan ()

    This method is deprecated.
    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

    public void startWps (WpsInfo config, 
                    WifiManager.WpsCallback listener)

    This method is deprecated.
    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

    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

    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

    public int updateNetwork (WifiConfiguration config)

    This method is deprecated.
    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.