Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

 

Show the video description

In this tutorial you will learn, how to programmatically activate and deactivate WiFi using the WifiManager class and it’s setWifiEnabled method.
For this we have to add the ACCESS_WIFI_STATE and the CHANGE_WIFI_STATE Manifest permissions.

AndroidManifest.xmlactivity_main.xmlMainActivity.java