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

# ZenPolicy.Builder

*** ** * ** ***

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


`
public
static
final

class
ZenPolicy.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.service.notification.ZenPolicy.Builder |

<br />

*** ** * ** ***

Builder class for `https://developer.android.com/reference/android/service/notification/ZenPolicy` objects.
Provides a convenient way to set the various fields of a `https://developer.android.com/reference/android/service/notification/ZenPolicy`. If a field
is not set, it is (@link STATE_UNSET} and will not change the current set policy.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#Builder()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowAlarms(boolean)(boolean allow) ` Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_ALARM` to play sounds and visually appear or to intercept them when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowAllSounds()() ` Allows all notifications to bypass DND and unmutes all streams. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowCalls(int)(int audienceType) ` Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_CALL` that match audienceType to play sounds and visually appear or to intercept them when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowConversations(int)(int audienceType) ` Whether to allow conversation notifications (see `https://developer.android.com/reference/android/app/NotificationChannel#setConversationId(java.lang.String,%20java.lang.String)`) that match audienceType to play sounds and visually appear or to intercept them when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowEvents(boolean)(boolean allow) ` Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_EVENT` to play sounds and visually appear or to intercept them when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowMedia(boolean)(boolean allow) ` Whether to allow media notifications to play sounds and visually appear or to intercept them when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowMessages(int)(int audienceType) ` Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_MESSAGE` that match audienceType to play sounds and visually appear or to intercept them when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowPriorityChannels(boolean)(boolean allow) ` Set whether priority channels are permitted to break through DND. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowReminders(boolean)(boolean allow) ` Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_REMINDER` to play sounds and visually appear or to intercept them when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowRepeatCallers(boolean)(boolean allow) ` Whether to allow repeat callers (notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_CALL` that have recently called to play sounds and visually appear. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#allowSystem(boolean)(boolean allow) ` Whether to allow system sounds to play when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#build()() ` Builds the current ZenPolicy. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#disallowAllSounds()() ` Intercepts all notifications and prevents them from playing sounds when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#hideAllVisualEffects()() ` Disallows notifications intercepted by DND from showing when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#showAllVisualEffects()() ` Allows notifications intercepted by DND to show on all surfaces when DND is active. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#showBadges(boolean)(boolean show) ` Whether `https://developer.android.com/reference/android/app/NotificationChannel#canShowBadge()` from notifications intercepted by DND are allowed on devices that support badging. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#showFullScreenIntent(boolean)(boolean show) ` Whether `https://developer.android.com/reference/android/app/Notification#fullScreenIntent` that are intercepted by DND are shown. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#showInAmbientDisplay(boolean)(boolean show) ` Whether notification intercepted by DND are prevented from appearing on ambient displays on devices that support ambient display. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#showInNotificationList(boolean)(boolean show) ` Whether notification intercepted by DND are prevented from appearing in notification list views like the notification shade or lockscreen on devices that support those views. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#showLights(boolean)(boolean show) ` Whether `https://developer.android.com/reference/android/app/NotificationChannel#shouldShowLights()` from notifications intercepted by DND are blocked. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#showPeeking(boolean)(boolean show) ` Whether notifications intercepted by DND are prevented from peeking. |
| ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | ` https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder#showStatusBarIcons(boolean)(boolean show) ` Whether notifications intercepted by DND are prevented from appearing in the status bar on devices that support status bars. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` 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 https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` 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` | ` 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` | ` 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 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

<br />

<br />

## Public methods

### allowAlarms

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

```
public ZenPolicy.Builder allowAlarms (boolean allow)
```

Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_ALARM`
to play sounds and visually appear or to intercept them when DND is active.
Disallowing alarms will mute the alarm stream when DND is active.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowAllSounds

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

```
public ZenPolicy.Builder allowAllSounds ()
```

Allows all notifications to bypass DND and unmutes all streams.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowCalls

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

```
public ZenPolicy.Builder allowCalls (int audienceType)
```

Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_CALL`
that match audienceType to play sounds and visually appear or to intercept
them when DND is active.

<br />

| Parameters ||
|---|---|
| `audienceType` | `int`: callers that are allowed to bypass DND. Value is one of the following: - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_UNSET` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_ANYONE` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_CONTACTS` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_STARRED` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_NONE` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowConversations

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

```
public ZenPolicy.Builder allowConversations (int audienceType)
```

Whether to allow conversation notifications
(see `https://developer.android.com/reference/android/app/NotificationChannel#setConversationId(java.lang.String,%20java.lang.String)`)
that match audienceType to play sounds and visually appear or to intercept
them when DND is active.

<br />

| Parameters ||
|---|---|
| `audienceType` | `int`: callers that are allowed to bypass DND. Value is one of the following: - `https://developer.android.com/reference/android/service/notification/ZenPolicy#CONVERSATION_SENDERS_UNSET` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#CONVERSATION_SENDERS_ANYONE` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#CONVERSATION_SENDERS_IMPORTANT` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#CONVERSATION_SENDERS_NONE` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowEvents

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

```
public ZenPolicy.Builder allowEvents (boolean allow)
```

Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_EVENT`
to play sounds and visually appear or to intercept them when DND is active.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowMedia

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

```
public ZenPolicy.Builder allowMedia (boolean allow)
```

Whether to allow media notifications to play sounds and visually
appear or to intercept them when DND is active.
Disallowing media will mute the media stream when DND is active.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowMessages

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

```
public ZenPolicy.Builder allowMessages (int audienceType)
```

Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_MESSAGE`
that match audienceType to play sounds and visually appear or to intercept
them when DND is active.

<br />

| Parameters ||
|---|---|
| `audienceType` | `int`: message senders that are allowed to bypass DND. Value is one of the following: - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_UNSET` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_ANYONE` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_CONTACTS` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_STARRED` - `https://developer.android.com/reference/android/service/notification/ZenPolicy#PEOPLE_TYPE_NONE` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowPriorityChannels

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

```
public ZenPolicy.Builder allowPriorityChannels (boolean allow)
```

Set whether priority channels are permitted to break through DND.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowReminders

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

```
public ZenPolicy.Builder allowReminders (boolean allow)
```

Whether to allow notifications with category `https://developer.android.com/reference/android/app/Notification#CATEGORY_REMINDER`
to play sounds and visually appear or to intercept them when DND is active.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowRepeatCallers

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

```
public ZenPolicy.Builder allowRepeatCallers (boolean allow)
```

Whether to allow repeat callers (notifications with category
`https://developer.android.com/reference/android/app/Notification#CATEGORY_CALL` that have recently called
to play sounds and visually appear.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### allowSystem

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

```
public ZenPolicy.Builder allowSystem (boolean allow)
```

Whether to allow system sounds to play when DND is active.
Disallowing system sounds will mute the system stream when DND is active.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### build

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

```
public ZenPolicy build ()
```

Builds the current ZenPolicy.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy` | This value cannot be `null`. <br /> |

### disallowAllSounds

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

```
public ZenPolicy.Builder disallowAllSounds ()
```

Intercepts all notifications and prevents them from playing sounds
when DND is active. Also mutes alarm, system and media streams.
Notification channels can still play sounds only if they
`https://developer.android.com/reference/android/app/NotificationChannel#canBypassDnd()`. If no channels can bypass DND,
the ringer stream is also muted.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### hideAllVisualEffects

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

```
public ZenPolicy.Builder hideAllVisualEffects ()
```

Disallows notifications intercepted by DND from showing when DND is active.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### showAllVisualEffects

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

```
public ZenPolicy.Builder showAllVisualEffects ()
```

Allows notifications intercepted by DND to show on all surfaces when DND is active.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### showBadges

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

```
public ZenPolicy.Builder showBadges (boolean show)
```

Whether `https://developer.android.com/reference/android/app/NotificationChannel#canShowBadge()` from
notifications intercepted by DND are allowed on devices that support badging.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### showFullScreenIntent

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

```
public ZenPolicy.Builder showFullScreenIntent (boolean show)
```

Whether `https://developer.android.com/reference/android/app/Notification#fullScreenIntent` that are intercepted
by DND are shown.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### showInAmbientDisplay

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

```
public ZenPolicy.Builder showInAmbientDisplay (boolean show)
```

Whether notification intercepted by DND are prevented from appearing on ambient displays
on devices that support ambient display.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### showInNotificationList

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

```
public ZenPolicy.Builder showInNotificationList (boolean show)
```

Whether notification intercepted by DND are prevented from appearing in notification
list views like the notification shade or lockscreen on devices that support those
views.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### showLights

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

```
public ZenPolicy.Builder showLights (boolean show)
```

Whether `https://developer.android.com/reference/android/app/NotificationChannel#shouldShowLights()` from
notifications intercepted by DND are blocked.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### showPeeking

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

```
public ZenPolicy.Builder showPeeking (boolean show)
```

Whether notifications intercepted by DND are prevented from peeking.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |

### showStatusBarIcons

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

```
public ZenPolicy.Builder showStatusBarIcons (boolean show)
```

Whether notifications intercepted by DND are prevented from appearing in the status bar
on devices that support status bars.

<br />

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

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/service/notification/ZenPolicy.Builder` | This value cannot be `null`. <br /> |