为什么 getCurrentInterruptionFilter BroadcastReceiver 在快速设置中起作用,但在设置中不起作用?

Why does getCurrentInterruptionFilter BroadcastReceiver work from Quick Settings but not from Settings?

我有以下广播接收器来掌握我的中断过滤器中的更改。

public class DndBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED);
        if (NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED.equals(intent.getAction())) {
            NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            assert mNotificationManager != null;
            if (mNotificationManager.getCurrentInterruptionFilter() == NotificationManager.INTERRUPTION_FILTER_NONE) {
                System.out.println("None");
            } else if (mNotificationManager.getCurrentInterruptionFilter() == NotificationManager.INTERRUPTION_FILTER_ALARMS) {
                System.out.println("Alarms");
            } else if (mNotificationManager.getCurrentInterruptionFilter() == NotificationManager.INTERRUPTION_FILTER_ALL) {
                System.out.println("All");
            } else if (mNotificationManager.getCurrentInterruptionFilter() == NotificationManager.INTERRUPTION_FILTER_PRIORITY) {
                System.out.println("Priority");
            } else if (mNotificationManager.getCurrentInterruptionFilter() == NotificationManager.INTERRUPTION_FILTER_UNKNOWN) {
                System.out.println("Unknown");
            }
        }
    }
}

当我切换“快速设置免打扰”按钮时效果非常好,但是当我使用实际设置面板中的按钮打开或关闭“免打扰”时,未检测到任何变化。有什么明显的原因吗?

好的,这是因为我的广播接收器仅在我的应用程序位于前台时才工作。所以快速设置有效,但不是设置,因为我在设置屏幕上。