NotificationManager.SetAutomaticZenRuleState(String, Condition) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Informs the notification manager that the state of an AutomaticZenRule
has changed.
[Android.Runtime.Register("setAutomaticZenRuleState", "(Ljava/lang/String;Landroid/service/notification/Condition;)V", "GetSetAutomaticZenRuleState_Ljava_lang_String_Landroid_service_notification_Condition_Handler", ApiSince=29)]
public virtual void SetAutomaticZenRuleState(string id, Android.Service.Notification.Condition condition);
[<Android.Runtime.Register("setAutomaticZenRuleState", "(Ljava/lang/String;Landroid/service/notification/Condition;)V", "GetSetAutomaticZenRuleState_Ljava_lang_String_Landroid_service_notification_Condition_Handler", ApiSince=29)>]
abstract member SetAutomaticZenRuleState : string * Android.Service.Notification.Condition -> unit
override this.SetAutomaticZenRuleState : string * Android.Service.Notification.Condition -> unit
Parameters
- id
- String
The id of the rule whose state should change
- condition
- Condition
The new state of this rule
- Attributes
Remarks
Informs the notification manager that the state of an AutomaticZenRule
has changed. Use this method to put the system into Do Not Disturb mode or request that it exits Do Not Disturb mode. The calling app must own the provided android.app.AutomaticZenRule
.
This method can be used in conjunction with or as a replacement to android.service.notification.ConditionProviderService#notifyCondition(Condition)
.
The condition change may be ignored if the user has activated or deactivated the rule manually -- the user can "override" the rule <em>this time</em>, with the rule resuming its normal operation for the next cycle. When this has happened, the supplied condition will be applied only once the automatic state is in agreement with the user-provided state. For example, assume that the AutomaticZenRule
corresponds to a "Driving Mode" with automatic driving detection.
<ol> <li>App detects driving and notifies the system that the rule should be active, calling this method with a Condition
with Condition#STATE_TRUE
). <li>User deactivates ("snoozes") the rule for some reason. This overrides the app-provided condition state. <li>App is still detecting driving, so again calls with Condition#STATE_TRUE
. This is ignored by the system, as the user override prevails. <li>Some time later, the app detects that driving stopped, so the rule should be inactive, and calls with Condition#STATE_FALSE
). This doesn't change the actual rule state (it was already inactive due to the user's override), but clears the override. <li>Some time later, the app detects that driving has started again, and notifies that the rule should be active (calling with Condition#STATE_TRUE
again). The rule is activated. </ol>
Note that the behavior at step #3 is different if the app also specifies Condition#SOURCE_USER_ACTION
as the Condition#source
-- rule state updates coming from user actions are not ignored.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.