I want to enable/disable wifi from my Android application. How can I do that?
To access this, go to “Settings -> Network & Internet” and select the Wi-Fi network. In some phones, it can be viewed as an icon. The data saver menu has a toggle switch which remains off. As soon as you turn it on, you will see a list of apps with Internet access that can be controlled.
Go to settings, then on Wireless and Network check to ensure that the WiFi icon is turned on. Alternatively, draw down the notification bar menu, then enable WiFi icon if it's off. Many users have reported having fixed android wifi problem by simply disabling airplane mode.
In the Android Mobile network settings, tap on Data usage. Next, tap on Network access. Now you see a list of all your installed apps and checkmarks for their access to mobile data and Wi-Fi. To block an app from accessing the internet, uncheck both boxes next to its name.
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifi.setWifiEnabled(false); // true or false to activate/deactivate wifi
You also need to request the permission in your AndroidManifest.xml :
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With