# AutomaticZenRule.Builder

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#inhmethods)  

# AutomaticZenRule.Builder

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder "View this page in Kotlin")\|Java

`
public
static
final

class
AutomaticZenRule.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|--------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.AutomaticZenRule.Builder |

<br />

*** ** * ** ***

## Summary

|                                                                                                                                        ### Public constructors                                                                                                                                         ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#Builder(android.app.AutomaticZenRule))`(`[AutomaticZenRule](https://developer.android.com/reference/android/app/AutomaticZenRule)` rule) `                                                                |
| ` `[Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#Builder(java.lang.String,%20android.net.Uri))`(`[String](https://developer.android.com/reference/java/lang/String)` name, `[Uri](https://developer.android.com/reference/android/net/Uri)` conditionId) ` |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[AutomaticZenRule](https://developer.android.com/reference/android/app/AutomaticZenRule)                 | ` `[build](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#build())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setConditionId](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setConditionId(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` conditionId) ` Sets the representation of the state that causes this rule to become active.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setConfigurationActivity](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setConfigurationActivity(android.content.ComponentName))`(`[ComponentName](https://developer.android.com/reference/android/content/ComponentName)` configurationActivity) ` Sets the configuration activity - an activity that handles[NotificationManager.ACTION_AUTOMATIC_ZEN_RULE](https://developer.android.com/reference/android/app/NotificationManager#ACTION_AUTOMATIC_ZEN_RULE)that shows the user more information about this rule and/or allows them to configure it.                                                                                                                                                                                                                                                                |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setDeviceEffects](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setDeviceEffects(android.service.notification.ZenDeviceEffects))`(`[ZenDeviceEffects](https://developer.android.com/reference/android/service/notification/ZenDeviceEffects)` deviceEffects) ` Sets the[ZenDeviceEffects](https://developer.android.com/reference/android/service/notification/ZenDeviceEffects)associated to this rule.                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setEnabled](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setEnabled(boolean))`(boolean enabled) ` Enables this rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setIconResId](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setIconResId(int))`(int iconResId) ` Sets a resource id of a tintable vector drawable representing the rule in image form.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setInterruptionFilter](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setInterruptionFilter(int))`(int interruptionFilter) ` Sets the interruption filter that is applied when this rule is active.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setManualInvocationAllowed](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setManualInvocationAllowed(boolean))`(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](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setName](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Sets the name of this rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setOwner](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setOwner(android.content.ComponentName))`(`[ComponentName](https://developer.android.com/reference/android/content/ComponentName)` owner) ` Sets the component name of the[ConditionProviderService](https://developer.android.com/reference/android/service/notification/ConditionProviderService)that manages this rule (but note that[ConditionProviderService](https://developer.android.com/reference/android/service/notification/ConditionProviderService)is deprecated in favor of using[NotificationManager.setAutomaticZenRuleState](https://developer.android.com/reference/android/app/NotificationManager#setAutomaticZenRuleState(java.lang.String,%20android.service.notification.Condition))to notify the system about the state of your rule). |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setTriggerDescription](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setTriggerDescription(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` description) ` Sets a user visible description of when this rule will be active (see[Condition.STATE_TRUE](https://developer.android.com/reference/android/service/notification/Condition#STATE_TRUE)).                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setType](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setType(int))`(int type) ` Sets the type of the rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` `[AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | ` `[setZenPolicy](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setZenPolicy(android.service.notification.ZenPolicy))`(`[ZenPolicy](https://developer.android.com/reference/android/service/notification/ZenPolicy)` policy) ` Sets the zen policy.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Builder

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder (AutomaticZenRule rule)
```

<br />

<br />

|                           Parameters                           ||
|--------|--------------------------------------------------------|
| `rule` | `AutomaticZenRule`: This value cannot be`null`. <br /> |

### Builder

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder (String name, 
                Uri conditionId)
```

<br />

<br />

|                         Parameters                          ||
|---------------|----------------------------------------------|
| `name`        | `String`: This value cannot be`null`. <br /> |
| `conditionId` | `Uri`: This value cannot be`null`. <br />    |

## Public methods

### build

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule build ()
```

<br />

<br />

|                                                           Returns                                                            ||
|------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule](https://developer.android.com/reference/android/app/AutomaticZenRule) | This value cannot be`null`. <br /> |

### setConditionId

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setConditionId (Uri conditionId)
```

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

<br />

|                        Parameters                        ||
|---------------|-------------------------------------------|
| `conditionId` | `Uri`: This value cannot be`null`. <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setConfigurationActivity

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setConfigurationActivity (ComponentName configurationActivity)
```

Sets the configuration activity - an activity that handles[NotificationManager.ACTION_AUTOMATIC_ZEN_RULE](https://developer.android.com/reference/android/app/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](https://developer.android.com/reference/android/service/notification/ConditionProviderService).

This is exclusive with[setOwner(ComponentName)](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setOwner(android.content.ComponentName)); rules where a configuration activity is set will not use the[ConditionProviderService](https://developer.android.com/reference/android/service/notification/ConditionProviderService)supplied there to determine whether the rule should be active.

<br />

|                                Parameters                                 ||
|-------------------------|--------------------------------------------------|
| `configurationActivity` | `ComponentName`: This value may be`null`. <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | <br /> |

### setDeviceEffects

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setDeviceEffects (ZenDeviceEffects deviceEffects)
```

Sets the[ZenDeviceEffects](https://developer.android.com/reference/android/service/notification/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](https://developer.android.com/reference/android/app/NotificationManager#updateAutomaticZenRule(java.lang.String,%20android.app.AutomaticZenRule)), a`null`value here means the previous set of effects is retained.

<br />

|                              Parameters                              ||
|-----------------|-----------------------------------------------------|
| `deviceEffects` | `ZenDeviceEffects`: This value may be`null`. <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | <br /> |

### setEnabled

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setEnabled (boolean enabled)
```

Enables this rule. Rules are enabled by default.

<br />

|         Parameters          ||
|-----------|------------------|
| `enabled` | `boolean` <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setIconResId

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setIconResId (int iconResId)
```

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

<br />

|        Parameters         ||
|-------------|--------------|
| `iconResId` | `int` <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setInterruptionFilter

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setInterruptionFilter (int interruptionFilter)
```

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

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                                                                                                                                                                                                      ||
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `interruptionFilter` | `int`: Value is[NotificationManager.INTERRUPTION_FILTER_NONE](https://developer.android.com/reference/android/app/NotificationManager#INTERRUPTION_FILTER_NONE),[NotificationManager.INTERRUPTION_FILTER_PRIORITY](https://developer.android.com/reference/android/app/NotificationManager#INTERRUPTION_FILTER_PRIORITY),[NotificationManager.INTERRUPTION_FILTER_ALARMS](https://developer.android.com/reference/android/app/NotificationManager#INTERRUPTION_FILTER_ALARMS),[NotificationManager.INTERRUPTION_FILTER_ALL](https://developer.android.com/reference/android/app/NotificationManager#INTERRUPTION_FILTER_ALL), or[NotificationManager.INTERRUPTION_FILTER_UNKNOWN](https://developer.android.com/reference/android/app/NotificationManager#INTERRUPTION_FILTER_UNKNOWN) <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setManualInvocationAllowed

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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.

<br />

|                Parameters                 ||
|-------------------------|------------------|
| `allowManualInvocation` | `boolean` <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setName

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setName (String name)
```

Sets the name of this rule.

<br />

|                      Parameters                      ||
|--------|----------------------------------------------|
| `name` | `String`: This value cannot be`null`. <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setOwner

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setOwner (ComponentName owner)
```

Sets the component name of the[ConditionProviderService](https://developer.android.com/reference/android/service/notification/ConditionProviderService)that manages this rule (but note that[ConditionProviderService](https://developer.android.com/reference/android/service/notification/ConditionProviderService)is deprecated in favor of using[NotificationManager.setAutomaticZenRuleState](https://developer.android.com/reference/android/app/NotificationManager#setAutomaticZenRuleState(java.lang.String,%20android.service.notification.Condition))to notify the system about the state of your rule).

This is exclusive with[setConfigurationActivity(ComponentName)](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder#setConfigurationActivity(android.content.ComponentName)); rules where a configuration activity is set will not use the component set here to determine whether the rule should be active.

<br />

|                        Parameters                         ||
|---------|--------------------------------------------------|
| `owner` | `ComponentName`: This value may be`null`. <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setTriggerDescription

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setTriggerDescription (String description)
```

Sets a user visible description of when this rule will be active (see[Condition.STATE_TRUE](https://developer.android.com/reference/android/service/notification/Condition#STATE_TRUE)).

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

<br />

|                        Parameters                        ||
|---------------|-------------------------------------------|
| `description` | `String`: This value may be`null`. <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setType

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setType (int type)
```

Sets the type of the rule.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | `int`: Value is[AutomaticZenRule.TYPE_UNKNOWN](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_UNKNOWN),[AutomaticZenRule.TYPE_OTHER](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_OTHER),[AutomaticZenRule.TYPE_SCHEDULE_TIME](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_SCHEDULE_TIME),[AutomaticZenRule.TYPE_SCHEDULE_CALENDAR](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_SCHEDULE_CALENDAR),[AutomaticZenRule.TYPE_BEDTIME](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_BEDTIME),[AutomaticZenRule.TYPE_DRIVING](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_DRIVING),[AutomaticZenRule.TYPE_IMMERSIVE](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_IMMERSIVE),[AutomaticZenRule.TYPE_THEATER](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_THEATER), or[AutomaticZenRule.TYPE_MANAGED](https://developer.android.com/reference/android/app/AutomaticZenRule#TYPE_MANAGED) <br /> |

|                                                                   Returns                                                                    ||
|----------------------------------------------------------------------------------------------------------|------------------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | This value cannot be`null`. <br /> |

### setZenPolicy

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public AutomaticZenRule.Builder setZenPolicy (ZenPolicy policy)
```

Sets the zen policy.

When updating an existing rule via[NotificationManager.updateAutomaticZenRule](https://developer.android.com/reference/android/app/NotificationManager#updateAutomaticZenRule(java.lang.String,%20android.app.AutomaticZenRule)), a`null`value here means the previous policy is retained.

<br />

|                       Parameters                       ||
|----------|----------------------------------------------|
| `policy` | `ZenPolicy`: This value may be`null`. <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/android/app/AutomaticZenRule.Builder) | <br /> |