2

Can any one tell me how to put a phone in Airplane mode programmatically with a single click on button in android?

Community
  • 1
  • 1
Born To Win
  • 3,319
  • 3
  • 19
  • 27
  • No Harshit..I want an airplane mode to be On programatically. – Born To Win Nov 13 '13 at 12:22
  • Does this answer your question? [How to set the AIRPLANE\_MODE\_ON to "True" or ON?](https://stackoverflow.com/questions/3249245/how-to-set-the-airplane-mode-on-to-true-or-on) – miken32 Oct 20 '22 at 16:47

2 Answers2

3

See the blog article http://dustinbreese.blogspot.in/2009/04/andoid-controlling-airplane-mode.html ,

Works only upto API 16

// Toggle airplane mode.
Settings.System.putInt(
      context.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);

where isEnabled is whether airplane mode is enabled or not.

kapil thadani
  • 1,425
  • 14
  • 26
-2
 this code to make phone silent

        AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
        am.setRingerMode(AudioManager.RINGER_MODE_SILENT);

there is also vibrate mode and normal mode

       am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
       am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
steevoo
  • 621
  • 6
  • 18
  • Thanks steevoo..I know these things but i want to on an airplane mode via programatically. – Born To Win Nov 13 '13 at 12:20
  • check this link http://stackoverflow.com/questions/13766909/how-to-programmatically-enable-and-disable-flight-mode-on-android-4-2 – steevoo Nov 13 '13 at 12:23