Android wifi operation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.