// 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);看看行不,飞行模式
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);看看行不,飞行模式