How to Turn off, Turn on Wifi in Android

The following code snippet will help you to pragmatically turn on and turn off wi-fi in android. This sample code is using android Switch (Available from android API level 14) to toggle between wi-fi state.

Turn on or off wifi in Android

We are done with the layout. Now let us move on to turn on wifi pragmatically. To do this e need to get the Wifi system service by calling getSystemService() method. After getting Wifi manager, we can check the state of WiFi by calling isWiiEnabled() method, before turning on.

Download Complete Example

A blogger, a bit of tech freak and a software developer. He is a thought leader in the fusion of design and mobile technologies. He is the author of Xamarin Mobile Application Development for Android Book (goo.gl/qUZ0XV3), DZone MVB and founder of stacktips.com.