Enable Disable WiFi programmatically in android on button click

Hello Guys. Welcome to our new tutorial of Enable Disable WiFi programmatically in android on button click. turn on and off wifi of your android device using the switch button. It is very simple to on wifi or off wifi from the android code.

please follow the code given below to Enable Disable WiFi programmatically in android on button click

  • First Create a new project in Android Studio
  • File ⇒ New Android ⇒ Application Project
  • Then Open src -> package -> MainActivity.java and then add following code :

JAVA (MainActivity.java)

  •  Now Open res -> layout -> activity_main.xml and then add following code :

XML (activity_main.xml)

Output:

Finally, run this project.

This is how application look like.

Enable Disable WiFi programmatically in android on button click Enable Disable WiFi programmatically in android on button click Enable Disable WiFi programmatically in android on button click

Leave a Reply

Your email address will not be published.