1. What is WIFI
WIFI is a wireless networking technology, and a common one is a wireless router. Then, the wireless router can be connected to the Internet through WIFI connection within the effective range of the radio wave coverage. If the wireless router is connected to an ADLS line or another network line, it is also called a "hot spot ".
2. obtain the status of the Wi-Fi network card
The status of a Wi-Fi network card is represented by a series of plastic constants.
1. WIFI_STATE_DISABLED: WIFI Nic unavailable (1)
2. WIFI_STATE_DISABLING: the WIFI Nic is being disabled (0)
3. WIFI_STATE_ENABLED: WIFI Nic available (3)
4. WIFI_STATE_ENABLING: the Wi-Fi network is on (2) it takes some time to start WIFI
5. WIFI_STATE_UNKNOWN: Unknown Nic status
3. permissions required to operate WIFI
CHANG. NETWORK. STATE
CHANG. NETWORK. WIFISTATE
ACCESS. NETWORK. STATE
ACCESS. NETWORK. WIFISTATE
4. Change the status of the Wi-Fi network card
1. You need to use the WIFIManager object to perform operations on the Wi-Fi network card. The method to obtain this object is as follows:
WIFIManager wifiManager = (wifiManager) Content. getSystemService (Service. WIFI_Service );
2. Enable the WIFI Nic
WifiManager. setwifiEnabled (true );
3. Disable the WIFI Nic
WifiManager. setwifiEnabled (false );
4. Obtain the NIC status
WifiManager. getwifistate ();
5. Note
1. You can only access the network with the added permission. Otherwise, insufficient permissions will be exposed.
2. implements is an internal
3. Activity is a subclass of Context.
Yuan Laiyuan's blog