我使用这段代码打开和关闭Android 4.1.2设备的飞行模式:
boolean isEnabled = Settings.System.getInt(
getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0) == 1;
Settings.System.putInt(
getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", !isEnabled);
sendBroadcast(intent);
但在阅读完文档后我感到困惑,因为这就是它所说的:
public static final String ACTION_AIRPLANE_MODE_CHANGED
Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or more radios have been turned off or on. The intent will have the following extra value:
state - A boolean value indicating whether Airplane Mode is on. If true, then cell radio and possibly other radios such as bluetooth or WiFi may have also been turned off
**This is a protected intent that can only be sent by the system.**
那么代码是如何工作的呢?当我说这是受保护的意图时我发送了这个意图?