# AutomaticZenRule.Builder

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

# Builder

*** ** * ** ***

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

```
class Builder
```

|---|------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                               ||
| ↳ | [android.app.AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) |

## Summary

|                                                                                                                                                              Public constructors                                                                                                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#Builder(android.app.AutomaticZenRule))`(`rule:` `[AutomaticZenRule](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule)`)` <br />                                                                                    |
| [Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#Builder(kotlin.String,%20android.net.Uri))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `conditionId:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)`)` <br /> |

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

## Public constructors

### Builder

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

```
Builder(rule: AutomaticZenRule)
```

|                                                             Parameters                                                              ||
|--------|-----------------------------------------------------------------------------------------------------------------------------|
| `rule` | [AutomaticZenRule](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule):This value cannot be`null`. |

### Builder

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

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

|                                                         Parameters                                                          ||
|---------------|--------------------------------------------------------------------------------------------------------------|
| `name`        | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |
| `conditionId` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#):This value cannot be`null`.      |

## Public methods

### build

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

```
fun build(): AutomaticZenRule
```

|                                                            Return                                                            ||
|-------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule) | This value cannot be`null`. |

### setConditionId

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

```
fun setConditionId(conditionId: Uri): AutomaticZenRule.Builder
```

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

|                                                       Parameters                                                       ||
|---------------|---------------------------------------------------------------------------------------------------------|
| `conditionId` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#):This value cannot be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setConfigurationActivity

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

```
fun setConfigurationActivity(configurationActivity: ComponentName?): AutomaticZenRule.Builder
```

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

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

|                                                                       Parameters                                                                       ||
|-------------------------|-------------------------------------------------------------------------------------------------------------------------------|
| `configurationActivity` | [ComponentName](https://developer.android.com/reference/kotlin/android/content/ComponentName.html#)?:This value may be`null`. |

### setDeviceEffects

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

```
fun setDeviceEffects(deviceEffects: ZenDeviceEffects?): AutomaticZenRule.Builder
```

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

|                                                                            Parameters                                                                             ||
|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `deviceEffects` | [ZenDeviceEffects](https://developer.android.com/reference/kotlin/android/service/notification/ZenDeviceEffects.html#)?:This value may be`null`. |

### setEnabled

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

```
fun setEnabled(enabled: Boolean): AutomaticZenRule.Builder
```

Enables this rule. Rules are enabled by default.

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setIconResId

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

```
fun setIconResId(iconResId: Int): AutomaticZenRule.Builder
```

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

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setInterruptionFilter

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

```
fun setInterruptionFilter(interruptionFilter: Int): AutomaticZenRule.Builder
```

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

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `interruptionFilter` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.app.NotificationManager#INTERRUPTION_FILTER_NONE](https://developer.android.com/reference/kotlin/android/app/NotificationManager#INTERRUPTION_FILTER_NONE:kotlin.Int),[android.app.NotificationManager#INTERRUPTION_FILTER_PRIORITY](https://developer.android.com/reference/kotlin/android/app/NotificationManager#INTERRUPTION_FILTER_PRIORITY:kotlin.Int),[android.app.NotificationManager#INTERRUPTION_FILTER_ALARMS](https://developer.android.com/reference/kotlin/android/app/NotificationManager#INTERRUPTION_FILTER_ALARMS:kotlin.Int),[android.app.NotificationManager#INTERRUPTION_FILTER_ALL](https://developer.android.com/reference/kotlin/android/app/NotificationManager#INTERRUPTION_FILTER_ALL:kotlin.Int), or[android.app.NotificationManager#INTERRUPTION_FILTER_UNKNOWN](https://developer.android.com/reference/kotlin/android/app/NotificationManager#INTERRUPTION_FILTER_UNKNOWN:kotlin.Int) |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setManualInvocationAllowed

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

```
fun setManualInvocationAllowed(allowManualInvocation: Boolean): AutomaticZenRule.Builder
```

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

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setName

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

```
fun setName(name: String): AutomaticZenRule.Builder
```

Sets the name of this rule.

|                                                      Parameters                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------|
| `name` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setOwner

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

```
fun setOwner(owner: ComponentName?): AutomaticZenRule.Builder
```

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

This is exclusive with[setConfigurationActivity](https://developer.android.com/reference/kotlin/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.

|                                                               Parameters                                                               ||
|---------|-------------------------------------------------------------------------------------------------------------------------------|
| `owner` | [ComponentName](https://developer.android.com/reference/kotlin/android/content/ComponentName.html#)?:This value may be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setTriggerDescription

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

```
fun setTriggerDescription(description: String?): AutomaticZenRule.Builder
```

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

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

|                                                        Parameters                                                         ||
|---------------|------------------------------------------------------------------------------------------------------------|
| `description` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?:This value may be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setType

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

```
fun setType(type: Int): AutomaticZenRule.Builder
```

Sets the type of the rule.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.app.AutomaticZenRule#TYPE_UNKNOWN](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_UNKNOWN:kotlin.Int),[android.app.AutomaticZenRule#TYPE_OTHER](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_OTHER:kotlin.Int),[android.app.AutomaticZenRule#TYPE_SCHEDULE_TIME](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_SCHEDULE_TIME:kotlin.Int),[android.app.AutomaticZenRule#TYPE_SCHEDULE_CALENDAR](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_SCHEDULE_CALENDAR:kotlin.Int),[android.app.AutomaticZenRule#TYPE_BEDTIME](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_BEDTIME:kotlin.Int),[android.app.AutomaticZenRule#TYPE_DRIVING](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_DRIVING:kotlin.Int),[android.app.AutomaticZenRule#TYPE_IMMERSIVE](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_IMMERSIVE:kotlin.Int),[android.app.AutomaticZenRule#TYPE_THEATER](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_THEATER:kotlin.Int), or[android.app.AutomaticZenRule#TYPE_MANAGED](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule#TYPE_MANAGED:kotlin.Int) |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [AutomaticZenRule.Builder](https://developer.android.com/reference/kotlin/android/app/AutomaticZenRule.Builder#) | This value cannot be`null`. |

### setZenPolicy

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

```
fun setZenPolicy(policy: ZenPolicy?): AutomaticZenRule.Builder
```

Sets the zen policy.

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

|                                                                  Parameters                                                                  ||
|----------|------------------------------------------------------------------------------------------------------------------------------------|
| `policy` | [ZenPolicy](https://developer.android.com/reference/kotlin/android/service/notification/ZenPolicy.html#)?:This value may be`null`. |