Hello Android Guys,
This is a simple tutorial which covers following parts:
1. Programatically turn on or turn off the wifi connection without going to setting option
in android. For this you have to do two things
A. Passing Permission inside your AndroidManifest.xml file:
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
B. Inside your Activity
I. For turning off the wifi
WifiManager wifiManager = (WifiManager)context.getSystemService
(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(false);
II. For turning on the wifi
WifiManager wifiManager = (WifiManager)context.getSystemService
(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(true);
Hope , this will Help some one.
Cheers :)
Happy Coding :)
0 comments:
Post a Comment