AutomaticZenRule.Builder


public static final class AutomaticZenRule.Builder
extends Object

java.lang.Object
   ↳ android.app.AutomaticZenRule.Builder


Summary

Public constructors

Builder(AutomaticZenRule rule)
Builder(String name, Uri conditionId)

Public methods

AutomaticZenRule build()
AutomaticZenRule.Builder setConditionId(Uri conditionId)

Sets the representation of the state that causes this rule to become active.

AutomaticZenRule.Builder setConfigurationActivity(ComponentName configurationActivity)

Sets the configuration activity - an activity that handles NotificationManager#ACTION_AUTOMATIC_ZEN_RULE that shows the user more information about this rule and/or allows them to configure it.

AutomaticZenRule.Builder setDeviceEffects(ZenDeviceEffects deviceEffects)

Sets the ZenDeviceEffects associated to this rule.

AutomaticZenRule.Builder setEnabled(boolean enabled)

Enables this rule.

AutomaticZenRule.Builder setIconResId(int iconResId)

Sets a resource id of a tintable vector drawable representing the rule in image form.

AutomaticZenRule.Builder setInterruptionFilter(int interruptionFilter)

Sets the interruption filter that is applied when this rule is active.

AutomaticZenRule.Builder setManualInvocationAllowed(boolean allowManualInvocation)

Sets whether this rule can be manually activated by the user even when the triggering condition for the rule is not met.

AutomaticZenRule.Builder setName(String name)

Sets the name of this rule.

AutomaticZenRule.Builder setOwner(ComponentName owner)

Sets the component name of the ConditionProviderService that manages this rule (but note that ConditionProviderService is deprecated in favor of using NotificationManager#setAutomaticZenRuleState to notify the system about the state of your rule).

AutomaticZenRule.Builder setTriggerDescription(String description)

Sets a user visible description of when this rule will be active (see Condition#STATE_TRUE).

AutomaticZenRule.Builder setType(int type)

Sets the type of the rule.

AutomaticZenRule.Builder setZenPolicy(ZenPolicy policy)

Sets the zen policy.

Inherited methods

Public constructors

Builder

Added in API level 35
public Builder (AutomaticZenRule rule)

Parameters
rule AutomaticZenRule: This value cannot be null.

Builder

Added in API level 35
public Builder (String name, 
                Uri conditionId)

Parameters
name String: This value cannot be null.

conditionId Uri: This value cannot be null.

Public methods

build

Added in API level 35
public AutomaticZenRule build ()

Returns
AutomaticZenRule This value cannot be null.

setConditionId

Added in API level 35
public AutomaticZenRule.Builder setConditionId (Uri conditionId)

Sets the representation of the state that causes this rule to become active.

Parameters
conditionId Uri: This value cannot be null.

Returns
AutomaticZenRule.Builder This value cannot be null.

setConfigurationActivity

Added in API level 35
public AutomaticZenRule.Builder setConfigurationActivity (ComponentName configurationActivity)

Sets the configuration activity - an activity that handles NotificationManager#ACTION_AUTOMATIC_ZEN_RULE that shows the user more information about this rule and/or allows them to configure it. This is required to be non-null for rules that are not backed by a ConditionProviderService.

This is exclusive with setOwner(ComponentName); rules where a configuration activity is set will not use the ConditionProviderService supplied there to determine whether the rule should be active.

Parameters
configurationActivity ComponentName: This value may be null.

Returns
AutomaticZenRule.Builder

setDeviceEffects

Added in API level 35
public AutomaticZenRule.Builder setDeviceEffects (ZenDeviceEffects deviceEffects)

Sets the ZenDeviceEffects associated to this rule. Device effects specify changes to the device behavior that should apply while the rule is active, but are not directly related to suppressing notifications (for example: disabling always-on display).

When updating an existing rule via NotificationManager#updateAutomaticZenRule, a null value here means the previous set of effects is retained.

Parameters
deviceEffects ZenDeviceEffects: This value may be null.

Returns
AutomaticZenRule.Builder

setEnabled

Added in API level 35
public AutomaticZenRule.Builder setEnabled (boolean enabled)

Enables this rule. Rules are enabled by default.

Parameters
enabled boolean

Returns
AutomaticZenRule.Builder This value cannot be null.

setIconResId

Added in API level 35
public AutomaticZenRule.Builder setIconResId (int iconResId)

Sets a resource id of a tintable vector drawable representing the rule in image form.

Parameters
iconResId int

Returns
AutomaticZenRule.Builder This value cannot be null.

setInterruptionFilter

Added in API level 35
public AutomaticZenRule.Builder setInterruptionFilter (int interruptionFilter)

Sets the interruption filter that is applied when this rule is active.

Parameters
interruptionFilter int: Value is NotificationManager.INTERRUPTION_FILTER_NONE, NotificationManager.INTERRUPTION_FILTER_PRIORITY, NotificationManager.INTERRUPTION_FILTER_ALARMS, NotificationManager.INTERRUPTION_FILTER_ALL, or NotificationManager.INTERRUPTION_FILTER_UNKNOWN

Returns
AutomaticZenRule.Builder This value cannot be null.

setManualInvocationAllowed

Added in API level 35
public AutomaticZenRule.Builder setManualInvocationAllowed (boolean allowManualInvocation)

Sets whether this rule can be manually activated by the user even when the triggering condition for the rule is not met.

Parameters
allowManualInvocation boolean

Returns
AutomaticZenRule.Builder This value cannot be null.

setName

Added in API level 35
public AutomaticZenRule.Builder setName (String name)

Sets the name of this rule.

Parameters
name String: This value cannot be null.

Returns
AutomaticZenRule.Builder This value cannot be null.

setOwner

Added in API level 35
public AutomaticZenRule.Builder setOwner (ComponentName owner)

Sets the component name of the ConditionProviderService that manages this rule (but note that ConditionProviderService is deprecated in favor of using NotificationManager#setAutomaticZenRuleState to notify the system about the state of your rule).

This is exclusive with setConfigurationActivity(ComponentName); rules where a configuration activity is set will not use the component set here to determine whether the rule should be active.

Parameters
owner ComponentName: This value may be null.

Returns
AutomaticZenRule.Builder This value cannot be null.

setTriggerDescription

Added in API level 35
public AutomaticZenRule.Builder setTriggerDescription (String description)

Sets a user visible description of when this rule will be active (see Condition#STATE_TRUE).

A description should be a (localized) string like "Mon-Fri, 9pm-7am" or "When connected to [Car Name]".

Parameters
description String: This value may be null.

Returns
AutomaticZenRule.Builder This value cannot be null.

setZenPolicy

Added in API level 35
public AutomaticZenRule.Builder setZenPolicy (ZenPolicy policy)

Sets the zen policy.

When updating an existing rule via NotificationManager#updateAutomaticZenRule, a null value here means the previous policy is retained.

Parameters
policy ZenPolicy: This value may be null.

Returns
AutomaticZenRule.Builder