Mustafa İrer Mustafa İrer - 10 days ago 4x
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?

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" />