static void toggle(Context context) { Log.i(TAG, "toggle airplane"); // We need to toggle the mode and also broadcast the fact. ContentResolver cr = context.getContentResolver(); boolean on = Settings.System.getInt(cr, Settings.System.AIRPLANE_MODE_ON, 0) != 0; Settings.System.putInt(cr, Settings.System.AIRPLANE_MODE_ON, on ? 0 : 1); // Post the intent. Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", !on); context.sendBroadcast(intent); }
Android 设置飞行模式
最新推荐文章于 2022-06-10 15:32:58 发布