WifiManager类详解

网上的,结合原文,用那个自动翻译的,备用一下:

public class WifiManager extends  Object

java.lang.Object

   ↳ android.net.wifi.WifiManager

类概述

此类提供用于管理 Wi-Fi 连接各个方面的主要 API。通过调用 获取此类的实例 Context.getSystemService(Context.WIFI_SERVICE)。它处理几类项目:

   已配置网络的列表。可以查看和更新​​该列表,并且可以修改单个条目的属性。

当前活动的 Wi-Fi 网络(如果有)。可以建立或断开连接,并且可以查询有关网络状态的动态信息。

接入点扫描的结果包含足够的信息来决定连接到哪个接入点。

它定义了在 Wi-Fi 状态发生任何变化时广播的各种 Intent 操作的名称。

这是执行 Wi-Fi 特定操作时使用的 API。要执行与抽象级别的网络连接相关的操作,请使用  ConnectivityManager。

摘要

嵌套类

class WifiManager.MulticastLock 允许应用程序接收 Wifi 多播数据包

class WifiManager.WifiLock 允许应用程序保持 Wi-Fi 无线电处于唤醒状态。

常量

String ACTION_PICK_WIFI_NETWORK 活动操作:选择要连接的 Wi-Fi 网络。

int ERROR_AUTHENTICATING 如果验证出现问题,则显示错误代码。

String EXTRA_BSSID  字符串的查找键,给出我们所连接的接入点的 BSSID。.

String EXTRA_NETWORK_INFO     NetworkInfo 与 Wi-Fi 网络关联的对象的查找键

String EXTRA_NEW_RSSI   查找键用于 int 给出新的 RSSI(以 dBm 为单位).

String EXTRA_NEW_STATE The  SupplicantState 描述新状态的 查找键使用 进行检索getParcelableExtra(String)。String EXTRA_PREVIOUS_WIFI_STATE 之前的 Wi-Fi 状态。

String EXTRA_SUPPLICANT_CONNECTED 布尔值的查找键,指示与请求方守护进程的连接是否已建立或丢失。

String EXTRA_SUPPLICANT_ERROR 查找键用于 SupplicantState 描述请求者错误代码(如果有),使用 进行检索 getIntExtra(String, int)。.

String EXTRA_WIFI_STATE 查找键为 int,指示 Wi-Fi 是启用、禁用、正在启用、禁用还是未知。.

String NETWORK_IDS_CHANGED_ACTION 配置的网络的网络 ID 可能已改变.

String NETWORK_STATE_CHANGED_ACTION 广播意图操作,表明 Wi-Fi 连接状态已改变.

String RSSI_CHANGED_ACTION        RSSI(信号强度)已改变.

String SCAN_RESULTS_AVAILABLE_ACTION 接入点扫描已完成,并且可从请求者处获得结果.

String SUPPLICANT_CONNECTION_CHANGE_ACTION 广播意图操作,表明与请求者的连接已建立(并且现在可以执行 Wi-Fi 操作)或与请求者的连接已丢失。.

String SUPPLICANT_STATE_CHANGED_ACTION 广播意图动作,表示与接入点建立连接的状态已经改变。一个额外功能提供了新的 SupplicantState。.

int WIFI_MODE_FULL 在此 Wi-Fi 锁定模式下,Wi-Fi 将保持活动状态并正常运行,即,它将尝试自动与范围内的记住的接入点建立连接,并且如果有记住的接入点但没有在范围内,它将进行定期扫描。e.

int WIFI_MODE_SCAN_ONLY 在这种 Wi-Fi 锁定模式下,Wi-Fi 将保持活动状态,但唯一支持的操作是启动扫描,以及随后报告扫描结果。.

String WIFI_STATE_CHANGED_ACTION 广播意图操作,表明 Wi-Fi 已启用、禁用、正在启用、禁用或未知.

int WIFI_STATE_DISABLED Wi-Fi 已禁用.

int WIFI_STATE_DISABLING Wi-Fi 当前已被禁用.

int WIFI_STATE_ENABLED 已启用 Wi-Fi.

int WIFI_STATE_ENABLING Wi-Fi 当前正在启用.

int WIFI_STATE_UNKNOWN Wi-Fi 处于未知状态。

https://blog.csdn.net/android_drawing/article/details/46916341

公有方法

int addNetwork( WifiConfiguration config)

Add a new network description to the set of configured networks.向已配置的网络集中添加新的网络描述

static int calculateSignalLevel(int rssi, int numLevels)

Calculates the level of the signal.计算信号的电平

static int compareSignalLevel(int rssiA, int rssiB)

Compares two signal strengths.比较两个信号强度

WifiManager.MulticastLock createMulticastLock( String tag)

Create a new MulticastLock  创建新的 MulticastLock

WifiManager.WifiLock createWifiLock(int lockType,  String tag)

Creates a new WifiLock.创建一个新的WifiLock

WifiManager.WifiLock createWifiLock( String tag)

Creates a new WifiLock.创建一个新的WifiLock。

boolean disableNetwork(int netId)

Disable a configured network.禁用已配置的网络。

boolean disconnect()

Disassociate from the currently active access point.取消与当前活动接入点的关联。

boolean enableNetwork(int netId, boolean disableOthers)

Allow a previously configured network to be associated with.允许与先前配置的网络关联。

List< WifiConfiguration> getConfiguredNetworks()

Return a list of all the networks configured in the supplicant.返回请求者中配置的所有网络的列表。

WifiInfo getConnectionInfo()

Return dynamic information about the current Wi-Fi connection, if any is active.如果有任何活动连接,则返回有关当前 Wi-Fi 连接的动态信息。

DhcpInfo getDhcpInfo()

Return the DHCP-assigned addresses from the last successful DHCP request, if any.返回上次成功的 DHCP 请求所分配的地址(如果有)。

List< ScanResult> getScanResults()

Return the results of the latest access point scan.返回最新接入点扫描的结果。

int getWifiState()

Gets the Wi-Fi enabled state.获取 Wi-Fi 启用状态

boolean isWifiEnabled()

Return whether Wi-Fi is enabled or disabled.返回 Wi-Fi 是否启用或禁用。

boolean pingSupplicant()

Check that the supplicant daemon is responding to requests.检查请求者守护进程是否正在响应请求

boolean reassociate()

Reconnect to the currently active access point, even if we are already connected.重新连接到当前活动的接入点,即使我们已经连接。

boolean reconnect()

Reconnect to the currently active access point, if we are currently disconnected.如果我们当前已断开连接,则重新连接到当前活动的接入点。

boolean removeNetwork(int netId)

Remove the specified network from the list of configured networks.从已配置网络列表中删除指定的网络。

boolean saveConfiguration()

Tell the supplicant to persist the current list of configured networks.告诉请求者保留当前配置的网络列表。

boolean setWifiEnabled(boolean enabled)

Enable or disable Wi-Fi.启用或禁用 Wi-Fi。

boolean startScan()

Request a scan for access points.请求扫描接入点

int updateNetwork( WifiConfiguration config)

Update the network description of an existing configured network.更新现有配置网络的网络描述。

继承的方法         来自 class java.lang.Object

常量

public static final String ACTION_PICK_WIFI_NETWORK  引入自: API 级别1

Activity Action: Pick a Wi-Fi network to connect to.活动操作:选择要连接的 Wi-Fi 网络。

Input: Nothing.

Output: Nothing.

常量值: "android.net.wifi.PICK_WIFI_NETWORK"

public static final int ERROR_AUTHENTICATING    引入自: API 级别1

The error code if there was a problem authenticating.如果验证出现问题,则显示错误代码。

常量值: 1 (0x00000001)

public static final String EXTRA_BSSID    引入自: API 级别1

The lookup key for a String giving the BSSID of the access point to which we are connected. Only present when the new state is CONNECTED. Retrieve with getStringExtra(String).字符串的查找键,提供我们连接的接入点的 BSSID。仅当新状态为 CONNECTED 时才存在。使用 进行检索 getStringExtra(String)。

常量值: "bssid"

public static final String EXTRA_NETWORK_INFO

引入自: API 级别1

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

 Retrieve with getParcelableExtra(String).NetworkInfo 与 Wi-Fi 网络关联的对象 的查找键 。使用 进行检索getParcelableExtra(String)

常量值: "networkInfo"

SupplicantState 描述新状态的 查找键使用 进行检索getParcelableExtra(String)

public static final String EXTRA_NEW_RSSI

引入自: API 级别1

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

查找键用于 int 给出新的 RSSI(以 dBm 为单位)

常量值: "newRssi"

public static final String EXTRA_NEW_STATE

引入自: API 级别1

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

SupplicantState 描述新状态的 查找键使用 进行检索getParcelableExtra(String)

常量值: "newState"

public static final String EXTRA_PREVIOUS_WIFI_STATE

引入自: API 级别1

The previous Wi-Fi state.之前的 Wi-Fi 状态

参见   EXTRA_WIFI_STATE

常量值: "previous_wifi_state"

public static final String EXTRA_SUPPLICANT_CONNECTED  引入自: API 级别1

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 getBooleanExtra(String, boolean)  .布尔值的查找键,指示与请求方守护进程的连接是已建立还是已丢失。 true 表示现在存在连接。 使用 检索它 getBooleanExtra(String, boolean)。

常量值: "connected"

public static final String EXTRA_SUPPLICANT_ERROR

引入自: API 级别1

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

查找键用于 SupplicantState 描述请求者错误代码(如果有),使用 进行检索 getIntExtra(String, int)。

参见   ERROR_AUTHENTICATING

常量值: "supplicantError"

public static final String EXTRA_WIFI_STATE

引入自: API 级别1

The lookup key for an int that indicates whether Wi-Fi is enabled, disabled, enabling, disabling, or unknown. Retrieve it with getIntExtra(String, int).查找键为一个 int,指示 Wi-Fi 是启用、禁用、正在启用、正在禁用还是未知。使用 检索它 getIntExtra(String, int)。

参见WIFI_STATE_DISABLED WIFI_STATE_DISABLING等

常量值: "wifi_state"

public static final String NETWORK_IDS_CHANGED_ACTION

引入自: API 级别1

The network IDs of the configured networks could have changed.配置的网络的网络 ID 可能已改变

常量值: "android.net.wifi.NETWORK_IDS_CHANGED"

public static final String NETWORK_STATE_CHANGED_ACTION   引入自: API 级别1

Broadcast intent action indicating that the state of Wi-Fi connectivity has changed. One extra provides the new state in the form of a NetworkInfo object. If the new state is CONNECTED, a second extra may provide the BSSID of the access point, as a String.广播意图操作,表明 Wi-Fi 连接状态已更改。一个 extra 以 NetworkInfo 对象的形式提供新状态。如果新状态为 CONNECTED,则第二个 extra 可能会以 的形式提供接入点的 BSSID  String。

参见   EXTRA_NETWORK_INFO  EXTRA_BSSID

常量值: "android.net.wifi.STATE_CHANGE"

public static final String RSSI_CHANGED_ACTION

引入自: API 级别1

The RSSI (signal strength) has changed.RSSI(信号强度)已改变。

参见  EXTRA_NEW_RSSI

常量值: "android.net.wifi.RSSI_CHANGED"

public static final String SCAN_RESULTS_AVAILABLE_ACTION

引入自: API 级别1

An access point scan has completed, and results are available from the supplicant. Call getScanResults() to obtain the results.接入点扫描已完成,并且请求方已提供结果。请致电 getScanResults() 获取结果

常量值: "android.net.wifi.SCAN_RESULTS"

public static final String SUPPLICANT_CONNECTION_CHANGE_ACTION

引入自: API 级别1

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.广播意图操作,表示已与请求方建立连接(现在可以执行 Wi-Fi 操作)或与请求方的连接已丢失。一个额外项以布尔值形式提供连接状态,其中 true 表示已连接

参见

EXTRA_SUPPLICANT_CONNECTED

常量值: "android.net.wifi.supplicant.CONNECTION_CHANGE"

public static final String SUPPLICANT_STATE_CHANGED_ACTION

引入自: API 级别1

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.广播意图操作,表示已与请求方建立连接(现在可以执行 Wi-Fi 操作)或与请求方的连接已丢失。一个额外项以布尔值形式提供连接状态,其中 true 表示已连接

参见  EXTRA_NEW_STATE EXTRA_SUPPLICANT_ERROR

常量值: "android.net.wifi.supplicant.STATE_CHANGE"

public static final int WIFI_MODE_FULL

引入自: API 级别3

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.在此 Wi-Fi 锁定模式下,Wi-Fi 将保持活动状态并正常运行,即,它将尝试自动与范围内的记住的接入点建立连接,并且如果有记住的接入点但没有在范围内,它将进行定期扫描。

常量值: 1 (0x00000001)

public static final int WIFI_MODE_SCAN_ONLY

引入自: API 级别3

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.在此 Wi-Fi 锁定模式下,Wi-Fi 将保持活动状态,但唯一支持的操作是启动扫描,然后报告扫描结果。不会尝试自动连接到记住的接入点,也不会自动执行定期扫描以查找记住的接入点。在此模式下,应用程序必须明确请求扫描。

常量值: 2 (0x00000002)

public static final String WIFI_STATE_CHANGED_ACTION

引入自: API 级别1

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.广播 Intent 操作,表明 Wi-Fi 已启用、已禁用、正在启用、已禁用或未知。一个 extra 以 int 形式提供此状态。另一个 extra 提供之前的状态(如果可用)。

参见  EXTRA_WIFI_STATE   EXTRA_PREVIOUS_WIFI_STATE

常量值: "android.net.wifi.WIFI_STATE_CHANGED"

public static final int WIFI_STATE_DISABLED

引入自: API 级别1

Wi-Fi is disabled.Wi-Fi 已禁用。

参见  WIFI_STATE_CHANGED_ACTION  getWifiState()

常量值: 1 (0x00000001)

public static final int WIFI_STATE_DISABLING

引入自: API 级别1

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

WIFI_STATE_DISABLED 当前正在禁用 Wi-Fi。如果成功完成,状态将变为 。

参见  WIFI_STATE_CHANGED_ACTION  getWifiState()

常量值: 0 (0x00000000)

public static final int WIFI_STATE_ENABLED

引入自: API 级别1

Wi-Fi is enabled.  已启用 Wi-Fi。

参见  WIFI_STATE_CHANGED_ACTION  getWifiState()

常量值: 3 (0x00000003)

public static final int WIFI_STATE_ENABLING

引入自: API 级别1

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

WIFI_STATE_ENABLED 当前正在启用 Wi-Fi。如果成功完成,状态将变为 。

参见  WIFI_STATE_CHANGED_ACTION  getWifiState()

常量值: 2 (0x00000002)

public static final int WIFI_STATE_UNKNOWN

引入自: API 级别1

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

Wi-Fi 处于未知状态。启用或禁用时发生错误时将出现此状态

参见  WIFI_STATE_CHANGED_ACTION  getWifiState()

常量值: 4 (0x00000004)

公有方法

public int addNetwork (WifiConfiguration config)

引入自: API 级别1

Add a new network description to the set of configured networks. The networkId field of the supplied configuration object is ignored.向已配置网络集添加新的网络描述。 networkId 提供的配置对象的字段将被忽略。

新网络默认标记为已禁用。要启用它,请调用 enableNetwork(int, boolean)

The new network will be marked DISABLED by default. To enable it, called enableNetwork(int, boolean).

参数

config the set of variables that describe the configuration, contained in a WifiConfiguration object.

配置 包含在对象中的描述配置的变量集 WifiConfiguration 。

返回值

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.新创建的网络描述的 ID。这在其他操作中用于指定要执行的操作网络。 -1 失败时返回。

public static int calculateSignalLevel (int rssi, int numLevels)

引入自: API 级别1

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

计算信号级别。每次显示信号时都应使用此方法

参数

rssi The power of the signal measured in RSSI.

接收信号强度 以 RSSI 为单位测量的信号功率。

级别数 计算级别中要考虑的级别数。

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

返回值

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

信号的级别,范围是 0 至 numLevels-1(包括这两个值)。

public static int compareSignalLevel (int rssiA, int rssiB)引入自: API 级别1

Compares two signal strengths.比较两个信号强度。

参数

rssiA The power of the first signal measured in RSSI.

以 RSSI 为单位测量的第一个信号的功率。

以 RSSI 为单位测量的第二个信号的功率。

rssiB The power of the second signal measured in RSSI.

返回值

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.如果第一个信号比第二个信号弱,则返回 <0;如果两个信号强度相同,则返回 0;如果第一个信号比第二个信号强,则返回 >0。

public WifiManager.MulticastLock createMulticastLock (String tag)引入自: API 级别4

Create a new MulticastLock创建新的 MulticastLock

参数

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

标签 MulticastLock 的标签,用于在调试消息中识别它。正常情况下,此字符串不会向用户显示,但如果应用程序拥有多个 MulticastLock,则应具有足够的描述性来识别应用程序及其中的特定 MulticastLock。

返回值

a new, unacquired MulticastLock with the given tag.具有给定标签的新的、未获取的 MulticastLock

参见  WifiManager.MulticastLock

public WifiManager.WifiLock createWifiLock (int lockType, String tag)引入自: API 级别3

Creates a new WifiLock.创建一个新的WifiLock。

参数

lockType the type of lock to create. See WIFI_MODE_FULL, and WIFI_MODE_SCAN_ONLY for descriptions of the types of Wi-Fi locks.

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

锁类型 要创建的锁的类型。请参阅 WIFI_MODE_FULL和 WIFI_MODE_SCAN_ONLY 了解 Wi-Fi 锁类型的描述。

标签 WifiLock 的标签,用于在调试消息中识别它。正常情况下,此字符串不会向用户显示,但如果应用程序包含多个 WifiLock,则应具有足够的描述性来识别应用程序及其中的特定 WifiLock。

返回值

a new, unacquired WifiLock with the given tag.具有给定标签的新的、未获取的 WifiLock

参见

WifiManager.WifiLock

public WifiManager.WifiLock createWifiLock (String tag)引入自: API 级别1

Creates a new WifiLock.创建一个新的WifiLock。

参数

标签 WifiLock 的标签,用于在调试消息中识别它。正常情况下,此字符串不会向用户显示,但如果应用程序包含多个 WifiLock,则应具有足够的描述性来识别应用程序及其中的特定 WifiLock。.

返回值

a new, unacquired WifiLock with the given tag.具有给定标签的新的、未获取的 WifiLock

参见  WifiManager.WifiLock

public boolean disableNetwork (int netId)

引入自: API 级别1

禁用已配置的网络。指定的网络将不会成为关联的候选。这可能会导致状态更改事件的异步传递。

参数

netId the ID of the network as returned by addNetwork(WifiConfiguration).

网络号 返回的网络ID  addNetwork(WifiConfiguration)。

返回值

true if the operation succeededtrue 如果操作成功

public boolean disconnect ()

引入自: API 级别1

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

解除与当前活动接入点的关联。这可能会导致状态改变事件的异步传递

返回值

true if the operation succeededtrue 如果操作成功

public boolean enableNetwork (int netId, boolean disableOthers)

引入自: API 级别1

Allow a previously configured network to be associated with. If disableOthers is true, then all other configured networks are disabled, and an attempt to connect to the selected network is initiated. This may result in the asynchronous delivery of state change events.允许与之前配置的网络关联。如果 disableOthers 为真,则所有其他配置的网络都将被禁用,并启动连接到所选网络的尝试。这可能会导致状态更改事件的异步传递。

参数

netId the ID of the network in the list of configured networks

网络号 已配置网络列表中的网络 ID

禁用其他 如果为 true,则禁用所有其他网络。选择要连接的特定网络的方式 true 为此参数指定

disableOthers if true, disable all other networks. The way to select a particular network to connect to is specify true for this parameter.

返回值

true if the operation succeededtrue 如果操作成功

public List<WifiConfiguration> getConfiguredNetworks ()

引入自: API 级别1

Return a list of all the networks configured in the supplicant. Not all fields of WifiConfiguration are returned. Only the following fields are filled in:返回客户端配置的所有网络列表,WifiConfiguration 字段不全部返回,仅填写以下字段:

networkId  网络编号

SSID   SSID

BSSID   BSSID

Priority   优先事项

allowedProtocols允许的协议

allowedKeyManagement允许密钥管理

allowedAuthAlgorithms允许的身份验证算法

allowedPairwiseCiphers 允许成对密码

allowedGroupCiphers  允许组密码

返回值

a list of network configurations in the form of a list of WifiConfiguration objects.以对象列表形式的网络配置列表 WifiConfiguration 。

public WifiInfo getConnectionInfo ()

引入自: API 级别1

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

如果有任何活动连接,则返回有关当前 Wi-Fi 连接的动态信息

返回值

the Wi-Fi information, contained in WifiInfo.中包含的 Wi-Fi 信息 WifiInfo。

public DhcpInfo getDhcpInfo ()

引入自: API 级别1

返回上次成功的 DHCP 请求所分配的地址(如果有)返回值

返回值

the DHCP information  DHCP 信息

public List<ScanResult> getScanResults ()

引入自: API 级别1

Return the results of the latest access point scan.返回最新接入点扫描的结果。

返回值

the list of access points found in the most recent scan.最近一次扫描中发现的接入点列表

public int getWifiState ()

引入自: API 级别1

Gets the Wi-Fi enabled state.获取 Wi-Fi 启用状态

返回值

以下之一 WIFI_STATE_DISABLED, WIFI_STATE_DISABLING, WIFI_STATE_ENABLED, WIFI_STATE_ENABLING, WIFI_STATE_UNKNOWN

参见 isWifiEnabled()

public boolean isWifiEnabled ()

引入自: API 级别1

Return whether Wi-Fi is enabled or disabled.返回 Wi-Fi 是否启用或禁用

返回值

true if Wi-Fi is enabledtrue 如果已启用 Wi-F

参见 getWifiState()

public boolean pingSupplicant ()

引入自: API 级别1

Check that the supplicant daemon is responding to requests.检查请求者守护进程是否正在响应请求。

返回值

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

public boolean reassociate ()

引入自: API 级别1

Reconnect to the currently active access point, even if we are already connected. This may result in the asynchronous delivery of state change events.重新连接到当前活动的接入点,即使我们已经连接。这可能会导致状态更改事件的异步传递

返回值

true if the operation succeededtrue 如果操作成功

public boolean reconnect ()

引入自: API 级别1

Reconnect to the currently active access point, if we are currently disconnected. This may result in the asynchronous delivery of state change events.如果当前已断开连接,则重新连接到当前活动的接入点。这可能会导致状态更改事件的异步传递

返回值

true if the operation succeededtrue 如果操作成功

public boolean removeNetwork (int netId)

引入自: API 级别1

Remove the specified network from the list of configured networks. This may result in the asynchronous delivery of state change events.从已配置网络列表中删除指定的网络。这可能会导致状态改变事件的异步传递

参数

netId the integer that identifies the network configuration to the supplicant

网络号 向请求者标识网络配置的整数

返回值

true if the operation succeededtrue 如果操作成功

public boolean saveConfiguration ()

引入自: API 级别1

Tell the supplicant 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.注意:此方法可能会更改现有网络的网络 ID。您应该假设调用此方法后网络 ID 可能会有所不同

返回值

true if the operation succeededtrue 如果操作成功

public boolean setWifiEnabled (boolean enabled)

引入自: API 级别1

Enable or disable Wi-Fi.启用或禁用 Wi-Fi

参数

enabled true to enable, false to disable.已启用 true 啟用, false 停用

返回值

true if the operation succeeds (or if the existing state is the same as the requested state).

true 如果操作成功(或者现有状态与请求的状态相同

public boolean startScan ()

引入自: API 级别1

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.请求扫描接入点。立即返回。扫描完成后,通过发送异步事件来告知结果的可用性

返回值

true if the operation succeeded, i.e., the scan was initiatedtrue 如果操作成功,即扫描已启动

public int updateNetwork (WifiConfiguration config)

引入自: API 级别1

Update the network description of an existing configured network.

更新现有配置网络的网络描述

参数

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

配置 描述配置的变量集,包含在对象中 WifiConfiguration 。它可能很稀疏,因此只有正在更改的项目才是非的null。 networkId 必须将该字段设置为正在更新的现有网络的 ID。

返回值

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.

成功时返回 networkId 提供的 WifiConfiguration 。 失败时

返回 -1 ,包括 networkId 当的字段 WifiConfiguration 不引用现有网络时

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值