Fields Summary |
---|
public static final int | ERROR_AUTHENTICATINGThe error code if there was a problem authenticating. |
public static final String | WIFI_STATE_CHANGED_ACTIONBroadcast 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 String | EXTRA_WIFI_STATEThe lookup key for an int that indicates whether Wi-Fi is enabled,
disabled, enabling, disabling, or unknown. Retrieve it with
{@link android.content.Intent#getIntExtra(String,int)}. |
public static final String | EXTRA_PREVIOUS_WIFI_STATEThe previous Wi-Fi state. |
public static final int | WIFI_STATE_DISABLINGWi-Fi is currently being disabled. The state will change to {@link #WIFI_STATE_DISABLED} if
it finishes successfully. |
public static final int | WIFI_STATE_DISABLEDWi-Fi is disabled. |
public static final int | WIFI_STATE_ENABLINGWi-Fi is currently being enabled. The state will change to {@link #WIFI_STATE_ENABLED} if
it finishes successfully. |
public static final int | WIFI_STATE_ENABLEDWi-Fi is enabled. |
public static final int | WIFI_STATE_UNKNOWNWi-Fi is in an unknown state. This state will occur when an error happens while enabling
or disabling. |
public static final String | SUPPLICANT_CONNECTION_CHANGE_ACTIONBroadcast 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 {@code true}
means CONNECTED. |
public static final String | EXTRA_SUPPLICANT_CONNECTEDThe lookup key for a boolean that indicates whether a connection to
the supplicant daemon has been gained or lost. {@code true} means
a connection now exists.
Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. |
public static final String | NETWORK_STATE_CHANGED_ACTIONBroadcast intent action indicating that the state of Wi-Fi connectivity
has changed. One extra provides the new state
in the form of a {@link android.net.NetworkInfo} object. If the new state is
CONNECTED, a second extra may provide the BSSID of the access point,
as a {@code String}. |
public static final String | EXTRA_NETWORK_INFOThe lookup key for a {@link android.net.NetworkInfo} object associated with the
Wi-Fi network. Retrieve with
{@link android.content.Intent#getParcelableExtra(String)}. |
public static final String | EXTRA_BSSIDThe 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
{@link android.content.Intent#getStringExtra(String)}. |
public static final String | SUPPLICANT_STATE_CHANGED_ACTIONBroadcast intent action indicating that the state of establishing a connection to
an access point has changed.One extra provides the new
{@link 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 String | EXTRA_NEW_STATEThe lookup key for a {@link SupplicantState} describing the new state
Retrieve with
{@link android.content.Intent#getParcelableExtra(String)}. |
public static final String | EXTRA_SUPPLICANT_ERRORThe lookup key for a {@link SupplicantState} describing the supplicant
error code if any
Retrieve with
{@link android.content.Intent#getIntExtra(String, int)}. |
public static final String | SCAN_RESULTS_AVAILABLE_ACTIONAn access point scan has completed, and results are available from the supplicant.
Call {@link #getScanResults()} to obtain the results. |
public static final String | RSSI_CHANGED_ACTIONThe RSSI (signal strength) has changed. |
public static final String | EXTRA_NEW_RSSIThe lookup key for an {@code int} giving the new RSSI in dBm. |
public static final String | NETWORK_IDS_CHANGED_ACTIONThe network IDs of the configured networks could have changed. |
public static final String | ACTION_PICK_WIFI_NETWORKActivity Action: Pick a Wi-Fi network to connect to.
Input: Nothing.
Output: Nothing. |
public static final int | WIFI_MODE_FULLIn 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_ONLYIn 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. |
private static final int | MIN_RSSIAnything worse than or equal to this will show 0 bars. |
private static final int | MAX_RSSIAnything better than or equal to this will show the max bars. |
IWifiManager | mService |
android.os.Handler | mHandler |
Methods Summary |
---|
public int | addNetwork(WifiConfiguration config)Add a new network description to the set of configured networks.
The {@code networkId} field of the supplied configuration object
is ignored.
The new network will be marked DISABLED by default. To enable it,
called {@link #enableNetwork}.
if (config == null) {
return -1;
}
config.networkId = -1;
return addOrUpdateNetwork(config);
|
private int | addOrUpdateNetwork(WifiConfiguration config)Internal method for doing the RPC that creates a new network description
or updates an existing one.
try {
return mService.addOrUpdateNetwork(config);
} catch (RemoteException e) {
return -1;
}
|
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.
if (rssi <= MIN_RSSI) {
return 0;
} else if (rssi >= MAX_RSSI) {
return numLevels - 1;
} else {
int partitionSize = (MAX_RSSI - MIN_RSSI) / (numLevels - 1);
return (rssi - MIN_RSSI) / partitionSize;
}
|
public static int | compareSignalLevel(int rssiA, int rssiB)Compares two signal strengths.
return rssiA - rssiB;
|
public android.net.wifi.WifiManager$WifiLock | createWifiLock(int lockType, java.lang.String tag)Creates a new WifiLock.
return new WifiLock(lockType, tag);
|
public android.net.wifi.WifiManager$WifiLock | createWifiLock(java.lang.String tag)Creates a new WifiLock.
return new WifiLock(WIFI_MODE_FULL, 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.
try {
return mService.disableNetwork(netId);
} catch (RemoteException e) {
return false;
}
|
public boolean | disconnect()Disassociate from the currently active access point. This may result
in the asynchronous delivery of state change events.
try {
return mService.disconnect();
} catch (RemoteException e) {
return false;
}
|
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.
try {
return mService.enableNetwork(netId, disableOthers);
} catch (RemoteException e) {
return false;
}
|
public java.util.List | 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
try {
return mService.getConfiguredNetworks();
} catch (RemoteException e) {
return null;
}
|
public WifiInfo | getConnectionInfo()Return dynamic information about the current Wi-Fi connection, if any is active.
try {
return mService.getConnectionInfo();
} catch (RemoteException e) {
return null;
}
|
public android.net.DhcpInfo | getDhcpInfo()Return the DHCP-assigned addresses from the last successful DHCP request,
if any.
try {
return mService.getDhcpInfo();
} catch (RemoteException e) {
return null;
}
|
public int | getNumAllowedChannels()Return the number of frequency channels that are allowed
to be used in the current regulatory domain.
try {
return mService.getNumAllowedChannels();
} catch (RemoteException e) {
return -1;
}
|
public java.util.List | getScanResults()Return the results of the latest access point scan.
try {
return mService.getScanResults();
} catch (RemoteException e) {
return null;
}
|
public int[] | getValidChannelCounts()Return the list of valid values for the number of allowed radio channels
for various regulatory domains.
try {
return mService.getValidChannelCounts();
} catch (RemoteException e) {
return null;
}
|
public int | getWifiState()Gets the Wi-Fi enabled state.
try {
return mService.getWifiEnabledState();
} catch (RemoteException e) {
return WIFI_STATE_UNKNOWN;
}
|
public boolean | isWifiEnabled()Return whether Wi-Fi is enabled or disabled.
return getWifiState() == WIFI_STATE_ENABLED;
|
public boolean | pingSupplicant()Check that the supplicant daemon is responding to requests.
if (mService == null)
return false;
try {
return mService.pingSupplicant();
} catch (RemoteException e) {
return false;
}
|
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.
try {
return mService.reassociate();
} catch (RemoteException e) {
return false;
}
|
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.
try {
return mService.reconnect();
} catch (RemoteException e) {
return false;
}
|
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.
try {
return mService.removeNetwork(netId);
} catch (RemoteException e) {
return false;
}
|
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.
try {
return mService.saveConfiguration();
} catch (RemoteException e) {
return false;
}
|
public boolean | setNumAllowedChannels(int numChannels)Set the number of frequency channels that are allowed to be used
in the current regulatory domain. This method should be used only
if the correct number of channels cannot be determined automatically
for some reason.
try {
return mService.setNumAllowedChannels(numChannels);
} catch (RemoteException e) {
return false;
}
|
public boolean | setWifiEnabled(boolean enabled)Enable or disable Wi-Fi.
try {
return mService.setWifiEnabled(enabled);
} catch (RemoteException e) {
return false;
}
|
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.
try {
return mService.startScan();
} catch (RemoteException e) {
return false;
}
|
public int | updateNetwork(WifiConfiguration config)Update the network description of an existing configured network.
if (config == null || config.networkId < 0) {
return -1;
}
return addOrUpdateNetwork(config);
|