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. Get an instance of this class by calling Context.getSystemService(Context.WIFI_SERVICE)
.
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
.
摘要
嵌套类
class
WifiManager.MulticastLock
Allows an application to receive Wifi Multicast packets.
class
WifiManager.WifiLock
Allows an application to keep the Wi-Fi radio awake.
常量
String
ACTION_PICK_WIFI_NETWORK
Activity Action: Pick a Wi-Fi network to connect to.
int
ERROR_AUTHENTICATING
The error code if there was a problem authenticating.
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_NEW_RSSI
The lookup key for an int
giving the new RSSI in dBm.
String
EXTRA_NEW_STATE
The lookup key for a SupplicantState
describing the
new state Retrieve with getParcelableExtra(String)
.
String
EXTRA_PREVIOUS_WIFI_STATE
The previous Wi-Fi state.
String
EXTRA_SUPPLICANT_CONNECTED
The lookup key for a boolean that indicates whether a connection to the supplicant daemon has been gained or lost.
String
EXTRA_SUPPLICANT_ERROR
The lookup key for a SupplicantState
describing the
supplicant error code if any Retrieve with getIntExtra(String,
int)
.
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 from the supplicant.
String
SUPPLICANT_CONNECTION_CHANGE_ACTION
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.
String
SUPPLICANT_STATE_CHANGED_ACTION
Broadcast intent action indicating that the state of establishing a connection to an access point has changed.One extra provides the new SupplicantState
.
int
WIFI_MODE_FULL
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.
int
WIFI_MODE_SCAN_ONLY
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.
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
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
WifiManager.WifiLock
createWifiLock(int
lockType, String tag)
Creates a new WifiLock.
WifiManager.WifiLock
createWifiLock(String tag)
Creates a new 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.
DhcpInfo
getDhcpInfo()
Return the DHCP-assigned addresses from the last successful DHCP request, if any.
List<ScanResult>
getScanResults()
Return the results of the latest access point scan.
int
getWifiState()
Gets the Wi-Fi enabled state.
boolean
isWifiEnabled()
Return whether Wi-Fi is enabled or disabled.
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.
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.
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"
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"
public static final String EXTRA_NEW_RSSI
引入自:API 级别1
The lookup key for an int
giving the new RSSI in 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)
.
常量值: "newState"
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)
.
常量值: "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)
.
常量值: "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)
.
參见
常量值: "wifi_state"
public static final String NETWORK_IDS_CHANGED_ACTION
引入自:API 级别1
The network IDs of the configured networks could have changed.
常量值: "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
.
常量值: "android.net.wifi.STATE_CHANGE"
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.
常量值: "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.
常量值: "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.
常量值: "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.
常量值: 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.
常量值: 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.
常量值: "android.net.wifi.WIFI_STATE_CHANGED"
public static final int WIFI_STATE_DISABLED
引入自:API 级别1
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.
常量值: 0 (0x00000000)
public static final int WIFI_STATE_ENABLED
引入自:API 级别1
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.
常量值: 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.
常量值: 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.
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.
返回值
- 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.
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.
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).
public static int compareSignalLevel (int rssiA, int rssiB)
引入自:API 级别1
Compares two signal strengths.
參数
rssiA
The power of the first signal measured in 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.
public WifiManager.MulticastLock createMulticastLock (String tag)
引入自:API 级别4
Create a new 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.
返回值
- a new, unacquired MulticastLock with the given tag.
public WifiManager.WifiLock createWifiLock (int
lockType, String tag)
引入自:API 级别3
Creates a new 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.
返回值
- a new, unacquired WifiLock with the given tag.
public WifiManager.WifiLock createWifiLock (String tag)
引入自:API 级别1
Creates a new WifiLock.
參数
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.
返回值
- a new, unacquired WifiLock with the given tag.
public boolean disableNetwork (int netId)
引入自:API 级别1
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.
參数
netId
the ID of the network as returned by addNetwork(WifiConfiguration)
.
返回值
true
if the operation succeeded
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 succeeded
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.
參数
netId
the ID of the network in the list of configured networks
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 succeeded
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:
- networkId
- SSID
- BSSID
- priority
- allowedProtocols
- allowedKeyManagement
- allowedAuthAlgorithms
- allowedPairwiseCiphers
- allowedGroupCiphers
返回值
- a list of network configurations in the form of a list of
WifiConfiguration
objects.
public WifiInfo getConnectionInfo ()
引入自:API 级别1
Return dynamic information about the current Wi-Fi connection, if any is active.
返回值
- the Wi-Fi information, contained in
WifiInfo
.
public DhcpInfo getDhcpInfo ()
引入自:API 级别1
Return the DHCP-assigned addresses from the last successful DHCP request, if any.
返回值
- the DHCP information
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 boolean isWifiEnabled ()
引入自:API 级别1
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 succeeded
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 succeeded
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 succeeded
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.
返回值
true
if the operation succeeded
public boolean setWifiEnabled (boolean enabled)
引入自:API 级别1
Enable or disable Wi-Fi.
參数
enabled
true
to enable, false
to disable.
返回值
true
if the operation succeeds (or if the existing state is the same as the requested state).
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 initiated
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.
返回值
- 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.
WifiManager
extends Object
java.lang.Object | |
↳ | android.net.wifi.WifiManager |
类概述
This class provides the primary API for managing all aspects of Wi-Fi connectivity. Get an instance of this class by calling Context.getSystemService(Context.WIFI_SERVICE)
.
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
.
摘要
嵌套类 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | WifiManager.MulticastLock | Allows an application to receive Wifi Multicast packets. | |||||||||
class | WifiManager.WifiLock | Allows an application to keep the Wi-Fi radio awake. |
常量 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ACTION_PICK_WIFI_NETWORK | Activity Action: Pick a Wi-Fi network to connect to. | |||||||||
int | ERROR_AUTHENTICATING | The error code if there was a problem authenticating. | |||||||||
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 theWi-Fi network. |
|||||||||
String | EXTRA_NEW_RSSI |
The lookup key for an int giving the new RSSI in dBm. |
|||||||||
String | EXTRA_NEW_STATE |
The lookup key for a SupplicantState describing thenew state Retrieve with getParcelableExtra(String) . |
|||||||||
String | EXTRA_PREVIOUS_WIFI_STATE | The previous Wi-Fi state. | |||||||||
String | EXTRA_SUPPLICANT_CONNECTED | The lookup key for a boolean that indicates whether a connection to the supplicant daemon has been gained or lost. | |||||||||
String | EXTRA_SUPPLICANT_ERROR |
The lookup key for a SupplicantState describing thesupplicant error code if any Retrieve with getIntExtra(String, . |
|||||||||
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 from the supplicant. | |||||||||
String | SUPPLICANT_CONNECTION_CHANGE_ACTION | 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. | |||||||||
String | SUPPLICANT_STATE_CHANGED_ACTION |
Broadcast intent action indicating that the state of establishing a connection to an access point has changed.One extra provides the new SupplicantState . |
|||||||||
int | WIFI_MODE_FULL |
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. |
|||||||||
int | WIFI_MODE_SCAN_ONLY | 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. | |||||||||
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 |
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
|
||||||||||
WifiManager.WifiLock |
createWifiLock(int lockType, String tag) Creates a new WifiLock.
|
||||||||||
WifiManager.WifiLock |
createWifiLock(String tag)
Creates a new 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.
|
||||||||||
DhcpInfo |
getDhcpInfo()
Return the DHCP-assigned addresses from the last successful DHCP request, if any.
|
||||||||||
List<ScanResult> |
getScanResults()
Return the results of the latest access point scan.
|
||||||||||
int |
getWifiState()
Gets the Wi-Fi enabled state.
|
||||||||||
boolean |
isWifiEnabled()
Return whether Wi-Fi is enabled or disabled.
|
||||||||||
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.
|
||||||||||
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
Activity Action: Pick a Wi-Fi network to connect to.
Input: Nothing.
Output: Nothing.
public static final int ERROR_AUTHENTICATING
The error code if there was a problem authenticating.
public static final String EXTRA_BSSID
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)
.
public static final String EXTRA_NETWORK_INFO
The lookup key for a NetworkInfo
object associated with the Wi-Fi network. Retrieve
with getParcelableExtra(String)
.
public static final String EXTRA_NEW_RSSI
The lookup key for an int
giving the new RSSI in dBm.
public static final String EXTRA_NEW_STATE
The lookup key for a SupplicantState
describing the new state Retrieve
with getParcelableExtra(String)
.
public static final String EXTRA_SUPPLICANT_CONNECTED
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)
public static final String EXTRA_SUPPLICANT_ERROR
The lookup key for a SupplicantState
describing the supplicant error code
if any Retrieve with getIntExtra(String, int)
.
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 getIntExtra(String,
.
int)
參见
public static final String NETWORK_IDS_CHANGED_ACTION
The network IDs of the configured networks could have changed.
public static final String NETWORK_STATE_CHANGED_ACTION
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
.
public static final String SCAN_RESULTS_AVAILABLE_ACTION
An access point scan has completed, and results are available from the supplicant. Call getScanResults()
to
obtain the results.
public static final String SUPPLICANT_CONNECTION_CHANGE_ACTION
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.
public static final String SUPPLICANT_STATE_CHANGED_ACTION
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.
public static final int WIFI_MODE_FULL
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.
public static final int WIFI_MODE_SCAN_ONLY
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.
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.
public static final int WIFI_STATE_DISABLED
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.
public static final int WIFI_STATE_ENABLED
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.
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.
公有方法
public int addNetwork (WifiConfiguration config)
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)
參数
config | the set of variables that describe the configuration, contained in a WifiConfiguration object. |
---|
返回值
- 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.
public static int calculateSignalLevel (int rssi, int numLevels)
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. |
---|---|
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).
public static int compareSignalLevel (int rssiA, int rssiB)
Compares two signal strengths.
參数
rssiA | The power of the first signal measured in 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.
public WifiManager.MulticastLock createMulticastLock (String tag)
Create a new 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. |
---|
返回值
- a new, unacquired MulticastLock with the given tag.
public WifiManager.WifiLock createWifiLock (int
lockType, String tag)
Creates a new WifiLock.
參数
lockType | the type of lock to create. See WIFI_MODE_FULL ,and WIFI_MODE_SCAN_ONLY for descriptions of the typesof 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. |
返回值
- a new, unacquired WifiLock with the given tag.
public WifiManager.WifiLock createWifiLock (String tag)
Creates a new WifiLock.
參数
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. |
---|
返回值
- a new, unacquired WifiLock with the given tag.
public boolean disableNetwork (int netId)
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.
參数
netId | the ID of the network as returned by addNetwork(WifiConfiguration) . |
---|
返回值
true
if the operation succeeded
public boolean disconnect ()
Disassociate from the currently active access point. This may result in the asynchronous delivery of state change events.
返回值
true
if the operation succeeded
public boolean enableNetwork (int netId, boolean disableOthers)
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.
參数
netId | the ID of the network in the list of configured networks |
---|---|
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 succeeded
public List<WifiConfiguration> getConfiguredNetworks ()
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:
- networkId
- SSID
- BSSID
- priority
- allowedProtocols
- allowedKeyManagement
- allowedAuthAlgorithms
- allowedPairwiseCiphers
- allowedGroupCiphers
返回值
- a list of network configurations in the form of a list of
WifiConfiguration
objects.
public WifiInfo getConnectionInfo ()
Return dynamic information about the current Wi-Fi connection, if any is active.
返回值
- the Wi-Fi information, contained in
WifiInfo
.
public DhcpInfo getDhcpInfo ()
Return the DHCP-assigned addresses from the last successful DHCP request, if any.
返回值
- the DHCP information
public List<ScanResult> getScanResults ()
Return the results of the latest access point scan.
返回值
- the list of access points found in the most recent scan.
public boolean isWifiEnabled ()
public boolean pingSupplicant ()
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 ()
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 succeeded
public boolean reconnect ()
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 succeeded
public boolean removeNetwork (int netId)
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 succeeded
public boolean saveConfiguration ()
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.
返回值
true
if the operation succeeded
public boolean setWifiEnabled (boolean enabled)
Enable or disable Wi-Fi.
參数
enabled | true to enable, false to disable. |
---|
返回值
true
if the operation succeeds (or if the existing state is the same as the requested state).
public boolean startScan ()
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 initiated
public int updateNetwork (WifiConfiguration config)
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 networkbeing updated. |
---|
返回值
- Returns the
networkId
of the suppliedWifiConfiguration
on success.
Returns-1
on failure, including when thenetworkId
field of theWifiConfiguration
does
not refer to an existing network.
WifiManager类具体解释的更多相关文章
- Java String类具体解释
Java String类具体解释 Java字符串类(java.lang.String)是Java中使用最多的类,也是最为特殊的一个类,非常多时候,我们对它既熟悉又陌生. 类结构: public fin ...
- Away3d 基础 1 ---对一个简单类的解释
转自:http://www.cnblogs.com/nooon/archive/2009/05/16/1458334.html 原英文地址: http://www.flashmagazine.com/ ...
- Java-WebSocket 项目的研究(三) WebSocketClient 类 具体解释
通过之前两篇文章 Java-WebSocket 项目的研究(一) Java-WebSocket类图描写叙述 Java-WebSocket 项目的研究(二) 小试身手:client连接server并发送 ...
- Explanation About Initilizing A DirextX3D Class 关于初始化Direct3D类的解释
目录 DirectX11 Study Note Create a DirectX graphics interface factory.创建一个DirectX图形界面工厂 CreateDXGIFact ...
- Java 反射的用法 有关Class类的解释
package com.imooc.test;public class ClassDemo1 { public static void main(String[] args) { Foo fool = ...
- Cocos2d-x3.1UserDefaule类具体解释
在Cocos2d-x存储数据使用的类是UserDefault类,以下分析下该类的使用 //.h #include "base/CCPlatformMacros.h" #includ ...
- java多线程Future和Callable类的解释与使用
一,描写叙述 在多线程下编程的时候.大家可能会遇到一种需求,就是我想在我开启的线程都结束时,同一时候获取每一个线程中返回的数据然后再做统一处理,在这种需求下,Future与Callable的组合就派 ...
- [图像类名词解释][ RGB YUV HSV相关解释说明]
一.概述 颜色通常用三个独立的属性来描述,三个独立变量综合作用,自然就构成一个空间坐标,这就是颜色空间.但被描述的颜色对象本身是客观的,不同颜色空间只是从不同的角度去衡量同一个对象.颜色空间按照基本机 ...
- Hibernate实体类注解解释
Hibernate注解1.@Entity(name="EntityName")必须,name为可选,对应数据库中一的个表2.@Table(name="",cat ...
随机推荐
- linux下图片转换工具[【转】
本文转载自:https://linux.cn/article-8014-1.html 计算机术语中,批处理指的是用一个非交互式的程序来执行一序列的任务的方法.这篇教程里,我们会使用 Linux 命令行 ...
- B1567 [JSOI2008]Blue Mary的战役地图 二分答案+hash
一开始以为是dp,后来看了一下标签...二分答案?之前也想过,但是没往下想,然后之后的算法就顺理成章,先求出第一个地图的所有子矩阵的hash值,然后求第二个,在上一个地图例二分查找,然后就没了. 算法 ...
- H3C路由器查看序列号信息
H3C MSR系列的路由器,查看本机的MAC地址.序列号信息和生产日期信息等可以使用dis device manuinfo 命令查看,以下是执行结果: slot 0 DEVICE_NAME ...
- BZOJ 1485 卡特兰数 数学
思路: 通过打表观察 这是个卡特兰数 但是它mod的数不是质数 怎么办呢 把所有数分解质因数好了 线性筛出mindiv 顺着mindiv分解质因数 复杂度$O(nlogn)$ //By Sirius ...
- Codeforces 680D Bear and Tower of Cubes 贪心 DFS
链接 Codeforces 680D Bear and Tower of Cubes 题意 求一个不超过 \(m\) 的最大体积 \(X\), 每次选一个最大的 \(x\) 使得 \(x^3\) 不超 ...
- Spring《七》ApplicationContext
1.国际化支持 getMessage()提供了国际化支持. Bean中必须定义为messageSource. <bean id="messageSource" class=& ...
- 利用jquery的ajaxPrefilter阻止重复发送请求
利用jquery的ajaxPrefilter阻止重复发送请求 (function ($) { var pendingRequests = {}; // 所有ajax请求的通用前置filter $.aj ...
- 【OpenCV】关于 waitKey()的使用方法
C++: int waitKey(int delay=0) cvWaitKey()函数的功能是不断刷新图像,频率时间为delay,单位为ms. 返回值为当前键盘按键值. 所以显示图像时,如果需要在cv ...
- 基于S3C2440数码相框
[参考]韦东山 教学笔记 1. 程序框架1.1 触摸屏: 主按线程,通过socket发给显示进程 --------------------------- 封装事件:ts线程 按键线程 -------- ...
- 02--读书笔记之:C++ Primer (第4版)及习题
推荐博客:http://www.cnblogs.com/xkfz007/archive/2012/08/15/2639381.html 第2章 数据和基本类型 1. 整型 2. 习题:左值和右值 3. ...