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:
Value | ||||
---|---|---|---|---|
String | ACTION_PICK_WIFI_NETWORK | Activity Action: Pick a Wi-Fi network to connect to. | "android.net.wifi.PICK_WIFI_NETWORK" | |
String | EXTRA_BSSID | The lookup key for a String giving the BSSID of the access point to which we are connected. | "bssid" | |
String | EXTRA_NETWORK_INFO | The lookup key for a NetworkInfo object associated with the Wi-Fi network. | "networkInfo" | |
String | EXTRA_NEW_RSSI | The lookup key for an int giving the new RSSI in dBm. |
"newRssi" | |
String | EXTRA_NEW_STATE | The lookup key for a SupplicantState describing the new state Retrieve with getParcelableExtra(String). | "newState" | |
String | EXTRA_PREVIOUS_WIFI_STATE | The previous Wi-Fi state. | "previous_wifi_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. | "connected" | |
String | EXTRA_WIFI_STATE | The lookup key for an int that indicates whether Wi-Fi is enabled, disabled, enabling, disabling, or unknown. | "wifi_state" | |
String | NETWORK_STATE_CHANGED_ACTION | Broadcast intent action indicating that the state of Wi-Fi connectivity has changed. | "android.net.wifi.STATE_CHANGE" | |
String | RSSI_CHANGED_ACTION | The RSSI (signal strength) has changed. | "android.net.wifi.RSSI_CHANGED" | |
String | SCAN_RESULTS_AVAILABLE_ACTION | An access point scan has completed, and results are available from the supplicant. | "android.net.wifi.SCAN_RESULTS" | |
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. | "android.net.wifi.supplicant.CONNECTION_CHANGE" | |
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. | "android.net.wifi.supplicant.STATE_CHANGE" | |
String | WIFI_STATE_CHANGED_ACTION | Broadcast intent action indicating that Wi-Fi has been enabled, disabled, enabling, disabling, or unknown. | "android.net.wifi.WIFI_STATE_CHANGED" | |
int | WIFI_STATE_DISABLED | Wi-Fi is disabled. | 1 | 0x00000001 |
int | WIFI_STATE_DISABLING | Wi-Fi is currently being disabled. | 0 | 0x00000000 |
int | WIFI_STATE_ENABLED | Wi-Fi is enabled. | 3 | 0x00000003 |
int | WIFI_STATE_ENABLING | Wi-Fi is currently being enabled. | 2 | 0x00000002 |
int | WIFI_STATE_UNKNOWN | Wi-Fi is in an unknown state. | 4 | 0x00000004 |
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. | ||||||
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. |
Input: Nothing.
Output: Nothing.
int
giving the new RSSI in dBm.
true
means
a connection now exists.
Retrieve it with getBooleanExtra(String, boolean).
String
.
true
means CONNECTED.
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. |
---|
-1
on failure.
rssi | The power of the signal measured in RSSI. |
---|---|
numLevels | The number of levels to consider in the calculated level. |
rssiA | The power of the first signal measured in RSSI. |
---|---|
rssiB | The power of the second signal measured in RSSI. |
netId | the ID of the network as returned by addNetwork(WifiConfiguration). |
---|
true
if the operation succeeded
true
if the operation succeeded
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
true
if Wi-Fi is enabledtrue
if we were able to communicate with the supplicant and
it returned the expected response to the PING message.
true
if the operation succeeded
true
if the operation succeeded
netId | the integer that identifies the network configuration to the supplicant |
---|
true
if the operation succeeded
true
if the operation succeeded
enabled | true to enable, false to disable. |
---|
true
if the operation succeeds (or if the existing state
is the same as the requested state).
true
if the operation succeeded, i.e., the scan was initiated
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. |
---|
networkId
of the supplied
WifiConfiguration
on success.
-1
on failure, including when the networkId
field of the WifiConfiguration
does not refer to an
existing network.
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:56 |