There is a code to disable and enable the Wi-Fi adapter:

String service = Context.WIFI_SERVICE; wifi = (WifiManager)getSystemService(service); public void Connected(){ if (!wifi.isWifiEnabled()){ if (wifi.getWifiState() != WifiManager.WIFI_STATE_ENABLING) wifi.setWifiEnabled(true); } 

But how to implement it in a widget?

Closed due to the fact that the essence of the issue is incomprehensible by the participants zRrr , Dmitry , Nick Volynkin , Suvitruf , Spawn 22 Nov '15 at 5:26 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • read about widgets, what's the problem? - Gorets
  • Well, for example, it uses the getSystemService method, which is implemented in the Activity class. - Qnex
  • @ Alexander Denisenko: you probably want to do everything in the OnClick handler? Do right right, there will be no problems. Send the event to the model, let it communicate with the Activity . - VladD