2

Androidのボタンを1回クリックするだけで、電話をプログラムで機内モードにする方法を教えてもらえますか?

4

3 に答える 3

3

ブログ記事http://dustinbreese.blogspot.in/2009/04/andoid-controlling-airplane-mode.htmlを参照してください。

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);

isEnabled は、機内モードが有効かどうかです。

于 2013-11-13T12:50:43.253 に答える
-2
 this code to make phone silent

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

バイブレーションモードと通常モードもあります

       am.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
       am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
于 2013-11-13T12:14:39.067 に答える