title: Trying to program how to turn wifi off on android device
body: <p>Had a read through the android documentation on WifiManager and thought I understood it but when I tried to code an example I keep running into problems.</p>
  
  <p>I had the following code</p>
  
  <pre><code>        wifiOffButton.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              Context mContext = getApplicationContext();
              WifiManager mWifi = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE);
              mWifi.setWifiEnabled(false);
          }
  
      });
  </code></pre>
  
  <p>I had tried something similar to turn off sound</p>
  
  <pre><code>muteButton.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              Context mContext = getApplicationContext();
              AudioManager mAudio = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
              mAudio.setRingerMode(0);
          }
      });
  </code></pre>
  
  <p>this works fine, but the wifi part always gives an error, was just wondering if I'm missing something obvious as I can't seem to work it out?</p>