Add <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></ uses-permission> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></ uses-permission>
to the manifest file On Sep 16, 4:36 am, "!oEL" <[email protected]> wrote: > Hi, > > Second question of the day, how do I programmatically turn on/off > WIFI? > > Currently I'm having something like this: > > _iWifi.setOnClickListener(new View.OnClickListener() { > > public void onClick(View v) { > WifiManager wm = (WifiManager) > getSystemService(WIFI_SERVICE); > > if (!wm.isWifiEnabled()) { > wm.setWifiEnabled(true); > } else { > wm.setWifiEnabled(false); > } > } > }); > > Where _iWifi is a button instant (of course...) > > Now, the problem is that it tells me there is a Security Exception > occurred, I guess I have no permission to access this. > > I'm sure a firmware key is not needed in this case (unlike my previous > question regarding reboot action), so what is the proper way of doing > this? > > Please help, thank you in advance :D --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

