Google is committed to advancing racial equity for Black communities. See how.

WifiInfo

public class WifiInfo
extends Object implements Parcelable

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


Describes the state of any Wi-Fi connection that is active or is in the process of being set up.

Summary

Nested classes

class WifiInfo.Builder

Builder for WifiInfo 

Constants

String FREQUENCY_UNITS

Frequency in MHz

String LINK_SPEED_UNITS

The unit in which links speeds are expressed.

int LINK_SPEED_UNKNOWN

Constant for unknown link speed.

Inherited constants

Public methods

String getBSSID()

Return the basic service set identifier (BSSID) of the current access point.

static NetworkInfo.DetailedState getDetailedStateOf(SupplicantState suppState)

Map a supplicant state into a fine-grained network connectivity state.

int getFrequency()

Returns the current frequency in FREQUENCY_UNITS.

boolean getHiddenSSID()
int getIpAddress()
int getLinkSpeed()

Returns the current link speed in LINK_SPEED_UNITS.

String getMacAddress()
int getMaxSupportedRxLinkSpeedMbps()

Returns the maximum supported receive link speed in Mbps

int getMaxSupportedTxLinkSpeedMbps()

Returns the maximum supported transmit link speed in Mbps

int getNetworkId()

Each configured network has a unique small integer ID, used to identify the network.

String getPasspointFqdn()

Returns the Fully Qualified Domain Name of the network if it is a Passpoint network.

String getPasspointProviderFriendlyName()

Returns the Provider Friendly Name of the network if it is a Passpoint network.

int getRssi()

Returns the received signal strength indicator of the current 802.11 network, in dBm.

int getRxLinkSpeedMbps()

Returns the current receive link speed in Mbps.

String getSSID()

Returns the service set identifier (SSID) of the current 802.11 network.

SupplicantState getSupplicantState()

Return the detailed state of the supplicant's negotiation with an access point, in the form of a SupplicantState object.

int getTxLinkSpeedMbps()

Returns the current transmit link speed in Mbps.

int getWifiStandard()

Get connection Wi-Fi standard

String toString()

Returns a string representation of the object.

Inherited methods

Constants

FREQUENCY_UNITS

Added in API level 21
public static final String FREQUENCY_UNITS

Frequency in MHz

Constant Value: "MHz"

Added in API level 1
public static final String LINK_SPEED_UNITS

The unit in which links speeds are expressed.

Constant Value: "Mbps"

Added in API level 29
public static final int LINK_SPEED_UNKNOWN

Constant for unknown link speed.

Constant Value: -1 (0xffffffff)

Public methods

getBSSID

Added in API level 1
public String getBSSID ()

Return the basic service set identifier (BSSID) of the current access point.

The BSSID may be null, if there is no network currently connected. "02:00:00:00:00:00", if the caller has insufficient permissions to access the BSSID.

Returns
String the BSSID, in the form of a six-byte MAC address: XX:XX:XX:XX:XX:XX

getDetailedStateOf

Added in API level 1
public static NetworkInfo.DetailedState getDetailedStateOf (SupplicantState suppState)

Map a supplicant state into a fine-grained network connectivity state.

Parameters
suppState SupplicantState: the supplicant state

Returns
NetworkInfo.DetailedState the corresponding DetailedState

getFrequency

Added in API level 21
public int getFrequency ()

Returns the current frequency in FREQUENCY_UNITS.

Returns
int the frequency.

See also:

getHiddenSSID

Added in API level 1
public boolean getHiddenSSID ()

Returns
boolean true if this network does not broadcast its SSID, so an SSID-specific probe request must be used for scans.

getIpAddress

Added in API level 1
public int getIpAddress ()

Returns
int

getLinkSpeed

Added in API level 1
public int getLinkSpeed ()

Returns the current link speed in LINK_SPEED_UNITS.

Returns
int the link speed or LINK_SPEED_UNKNOWN if link speed is unknown.

getMacAddress

Added in API level 1
public String getMacAddress ()

Returns
String

getMaxSupportedRxLinkSpeedMbps

Added in API level 30
public int getMaxSupportedRxLinkSpeedMbps ()

Returns the maximum supported receive link speed in Mbps

Returns
int the max supported Rx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. @see #LINK_SPEED_UNKNOWN

getMaxSupportedTxLinkSpeedMbps

Added in API level 30
public int getMaxSupportedTxLinkSpeedMbps ()

Returns the maximum supported transmit link speed in Mbps

Returns
int the max supported tx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. @see #LINK_SPEED_UNKNOWN

getNetworkId

Added in API level 1
public int getNetworkId ()

Each configured network has a unique small integer ID, used to identify the network. This method returns the ID for the currently connected network.

The networkId may be -1 if there is no currently connected network or if the caller has insufficient permissions to access the network ID.

Returns
int the network ID.

getPasspointFqdn

Added in API level 29
public String getPasspointFqdn ()

Returns the Fully Qualified Domain Name of the network if it is a Passpoint network.

The FQDN may be null if no network currently connected, currently connected network is not passpoint network or the caller has insufficient permissions to access the FQDN.

Returns
String

getPasspointProviderFriendlyName

Added in API level 29
public String getPasspointProviderFriendlyName ()

Returns the Provider Friendly Name of the network if it is a Passpoint network.

The Provider Friendly Name may be null if no network currently connected, currently connected network is not passpoint network or the caller has insufficient permissions to access the Provider Friendly Name.

Returns
String

getRssi

Added in API level 1
public int getRssi ()

Returns the received signal strength indicator of the current 802.11 network, in dBm.

Use WifiManager.calculateSignalLevel(int) to convert this number into an absolute signal level which can be displayed to a user.

Returns
int the RSSI.

getRxLinkSpeedMbps

Added in API level 29
public int getRxLinkSpeedMbps ()

Returns the current receive link speed in Mbps.

Returns
int the Rx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. Value is -1 or greater

See also:

getSSID

Added in API level 1
public String getSSID ()

Returns the service set identifier (SSID) of the current 802.11 network.

If the SSID can be decoded as UTF-8, it will be returned surrounded by double quotation marks. Otherwise, it is returned as a string of hex digits. The SSID may be WifiManager#UNKNOWN_SSID, if there is no network currently connected or if the caller has insufficient permissions to access the SSID.

Prior to Build.VERSION_CODES.JELLY_BEAN_MR1, this method always returned the SSID with no quotes around it.

Returns
String the SSID.

getSupplicantState

Added in API level 1
public SupplicantState getSupplicantState ()

Return the detailed state of the supplicant's negotiation with an access point, in the form of a SupplicantState object.

Returns
SupplicantState the current SupplicantState

getTxLinkSpeedMbps

Added in API level 29
public int getTxLinkSpeedMbps ()

Returns the current transmit link speed in Mbps.

Returns
int the Tx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. Value is -1 or greater

See also:

getWifiStandard

Added in API level 30
public int getWifiStandard ()

Get connection Wi-Fi standard

Returns
int the connection Wi-Fi standard Value is ScanResult.WIFI_STANDARD_UNKNOWN, ScanResult.WIFI_STANDARD_LEGACY, ScanResult.WIFI_STANDARD_11N, ScanResult.WIFI_STANDARD_11AC, or ScanResult.WIFI_STANDARD_11AX

toString

Added in API level 1
public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.