跳转到相应内容

最常访问

最近访问

navigation

WifiInfo

public class WifiInfo
extends Object implements Parcelable

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


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

Summary

Constants

String FREQUENCY_UNITS

Frequency in MHz

String LINK_SPEED_UNITS

Link speed in Mbps

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 getNetworkId()

Each configured network has a unique small integer ID, used to identify the network when performing operations on the supplicant.

int getRssi()

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

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.

String toString()

Returns a string representation of the object.

Inherited methods

Constants

FREQUENCY_UNITS

added in API level 21
String FREQUENCY_UNITS

Frequency in MHz

Constant Value: "MHz"

LINK_SPEED_UNITS

added in API level 1
String LINK_SPEED_UNITS

Link speed in Mbps

Constant Value: "Mbps"

Public methods

getBSSID

added in API level 1
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.

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

getFrequency

added in API level 21
int getFrequency ()

Returns the current frequency in FREQUENCY_UNITS.

Returns
int the frequency.

See also:

getHiddenSSID

added in API level 1
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
int getIpAddress ()

Returns
int

getLinkSpeed

added in API level 1
int getLinkSpeed ()

Returns the current link speed in LINK_SPEED_UNITS.

Returns
int the link speed.

See also:

getMacAddress

added in API level 1
String getMacAddress ()

Returns
String

getNetworkId

added in API level 1
int getNetworkId ()

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

Returns
int the network ID, or -1 if there is no currently connected network

getRssi

added in API level 1
int getRssi ()

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

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

Returns
int the RSSI.

getSSID

added in API level 1
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 <unknown ssid> if there is no network currently connected, or if the caller has insufficient permissions to access the SSID. Prior to JELLY_BEAN_MR1, this method always returned the SSID with no quotes around it.

Returns
String the SSID

getSupplicantState

added in API level 1
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

toString

added in API level 1
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.

此网站会使用 Cookie 来存储您在此网站上指定的语言和显示选项偏好设置。

获取最新的 Android Developers 资讯和提示,助您在 Google Play 上取得成功。

* 必填字段

成功!

在微信上关注 Google Developers

要以浏览此网站吗?

您请求访问的是网页,但是您为此网站设置的语言偏好为

要更改您的语言偏好设置并以浏览此网站吗?如果以后您想要更改语言偏好设置,请使用每个页面底部的语言菜单。

该类需要 或更高的 API 级别

此文档已被隐藏,因为您为该文档选择的 API 级别是 。您可以使用左侧导航栏上方的选择器来更改文档的 API 级别。

要详细了解如何根据您的应用需求指定 API 级别,请参阅支持不同平台版本

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)