title: turn off airplane mode in Android
body: <p>I would like to turn off the airplane mode if num>50, I implemented this code (from <a href="https://stackoverflow.com/questions/5533881/toggle-airplane-mode-in-android">Toggle airplane mode in Android</a>) but when executed I get a force close, can any one help here?</p>
  
  <pre><code>                if(num&gt;50){
                      // read the airplane mode setting
                      boolean isEnabled = Settings.System.getInt(
                            getContentResolver(), 
                            Settings.System.AIRPLANE_MODE_ON, 0) == 1;
  
                      // toggle airplane mode
                      Settings.System.putInt(
                            getContentResolver(),
                            Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
  
                      // Post an intent to reload
                      Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
                      intent.putExtra("state", !isEnabled);
                      sendBroadcast(intent);
  
  
  
                  }
  </code></pre>
  
  <p>o.k. I implemented the premonitions but i would like to change the if statement:</p>
  
  <pre><code>if num&gt;=50 and airplane mode=on toggle it off 
  if  airplane mode=off and num&lt;50 toggle it on
  </code></pre>
  
  <p>Can some one help me writing the new code? (I'm a newbie) </p>