This example describes the basics of Android's WiFi development. Share to everyone for your reference. Specifically as follows:
Android provides the Wifimanager class, which enables WiFi-related operations.
Pass
You can get an instance of the class.
1. Get WiFi on (as long as WiFi on the phone is turned on and is not connected to a WiFi connection):
Boolean isOpen = wifimanager.iswifienabled ();
2. Modify WiFi status, through the parameters to open WiFi or turn off WiFi
Wifimanager.setwifienabled (TRUE);
3. Access to nearby WiFi (must be in the case of WiFi already open)
list<scanresult> list = Wifimanager.getscanresults ();
4. Get the WiFi on the current connection
Wifiinfo wifiinfo = Wifimanager.getconnectioninfo ();
5. Get the current list of WiFi configurations (that is, the WiFi list displayed on the page when the phone is connected to WiFi)
list<wificonfiguration> configlist = Wifimanager.getconfigurednetworks ();
6. Connect/Disconnect Some WiFi (note: WiFi will not change the open state)
Connection, the first parameter is the net ID of a WiFi that is returned in Wifimanager.getconfigurednetworks () or Wifimanager.getconnectioninfo (). The second parameter is whether to turn off other WiFi while connecting to the WiFi
Wifimanager.enablenetwork (NetID, true);
Disconnect, parameter meaning ditto
Wifimanager.disablenetwork (NetID);
Wifimanager.disconnect ();
Full instance code click here to download the site.
I hope this article will help you with your Android program.