WiFi operations and Instances

Source: Internet
Author: User

 

1. What is WiFi
Protocol for accessing the Internet using a wireless router
2. obtain the status of the Wi-Fi network card
The status of the Wi-Fi network card is represented by a series of plastic constants.
Stateful:
The value of wifi_state_disabled is 1.
The value of wifi_state_disabling being disabled for the NIC is 0.
The value of available wifi_state_enabled for the NIC is 3.
The value of wifi_state_enabling is 2.
The value of the unknown Nic status wifi_state_unknown is 4.
3. permissions required to operate WiFi
Note: The permission setting class in Android is manifest. permission.
4. Change the status of the Wi-Fi network card
To perform operations on NICs, you must use the core wifimanager object.
Important methods:
Method to obtain this object:
Wifimanager = context. getsystemservice (context. wifi_service );
Enable WiFi Nic
Wifimanager. setwifienabled (true );
Disable WiFi Nic
Wifimanager. setwifienabled (false );
Obtain the current Nic status
Wifimanager. getwifistate ();
Set permissions in the main configuration file:
<! -- Set the four permissions to access the network status and WiFi status, and change the network status and WiFi status. -->
<Uses-Permission Android: Name = "android. Permission. change_network_state"> </uses-Permission>
<Uses-Permission Android: Name = "android. Permission. change_wifi_state"> </uses-Permission>
<Uses-Permission Android: Name = "android. Permission. access_network_state"> </uses-Permission>
<Uses-Permission Android: Name = "android. Permission. access_wifi_state"> </uses-Permission>

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.