Mustafa İrer Mustafa İrer - 1 year ago 74
Android Question

How to enable/disable WiFi from an application?

I want to enable/disable wireless from my Android application. How can I do that?

Answer Source
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" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download