Mustafa İrer Mustafa İrer - 1 month ago 10
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
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" />