Mustafa İrer Mustafa İrer - 6 months ago 43
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" />