Added in API level 29

Builder


class Builder
kotlin.Any
   ↳ android.service.notification.ZenPolicy.Builder

Builder class for ZenPolicy objects. Provides a convenient way to set the various fields of a ZenPolicy. If a field is not set, it is (@link STATE_UNSET} and will not change the current set policy.

Summary

Public constructors

Public methods
ZenPolicy.Builder

Whether to allow notifications with category Notification#CATEGORY_ALARM to play sounds and visually appear or to intercept them when DND is active.

ZenPolicy.Builder

Allows all notifications to bypass DND and unmutes all streams.

ZenPolicy.Builder
allowCalls(audienceType: Int)

Whether to allow notifications with category Notification#CATEGORY_CALL that match audienceType to play sounds and visually appear or to intercept them when DND is active.

ZenPolicy.Builder
allowConversations(audienceType: Int)

Whether to allow conversation notifications (see NotificationChannel#setConversationId(String, String)) that match audienceType to play sounds and visually appear or to intercept them when DND is active.

ZenPolicy.Builder

Whether to allow notifications with category Notification#CATEGORY_EVENT to play sounds and visually appear or to intercept them when DND is active.

ZenPolicy.Builder

Whether to allow media notifications to play sounds and visually appear or to intercept them when DND is active.

ZenPolicy.Builder
allowMessages(audienceType: Int)

Whether to allow notifications with category Notification#CATEGORY_MESSAGE that match audienceType to play sounds and visually appear or to intercept them when DND is active.

ZenPolicy.Builder

Set whether priority channels are permitted to break through DND.

ZenPolicy.Builder

Whether to allow notifications with category Notification#CATEGORY_REMINDER to play sounds and visually appear or to intercept them when DND is active.

ZenPolicy.Builder

Whether to allow repeat callers (notifications with category Notification#CATEGORY_CALL that have recently called to play sounds and visually appear.

ZenPolicy.Builder

Whether to allow system sounds to play when DND is active.

ZenPolicy

Builds the current ZenPolicy.

ZenPolicy.Builder

Intercepts all notifications and prevents them from playing sounds when DND is active.

ZenPolicy.Builder

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

ZenPolicy.Builder

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

ZenPolicy.Builder

Whether badges from notifications intercepted by DND are allowed on devices that support badging.

ZenPolicy.Builder

Whether full screen intents that are intercepted by DND are shown.

ZenPolicy.Builder

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

ZenPolicy.Builder

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.

ZenPolicy.Builder

Whether notification lights from notifications intercepted by DND are blocked.

ZenPolicy.Builder

Whether notifications intercepted by DND are prevented from peeking.

ZenPolicy.Builder

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

Public constructors

Builder

Added in API level 29
Builder()

Public methods

allowAlarms

Added in API level 29
fun allowAlarms(allow: Boolean): ZenPolicy.Builder

Whether to allow notifications with category 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.

Return
ZenPolicy.Builder This value cannot be null.

allowAllSounds

Added in API level 29
fun allowAllSounds(): ZenPolicy.Builder

Allows all notifications to bypass DND and unmutes all streams.

Return
ZenPolicy.Builder This value cannot be null.

allowCalls

Added in API level 29
fun allowCalls(audienceType: Int): ZenPolicy.Builder

Whether to allow notifications with category Notification#CATEGORY_CALL that match audienceType to play sounds and visually appear or to intercept them when DND is active.

Parameters
audienceType Int: callers that are allowed to bypass DND Value is android.service.notification.ZenPolicy#PEOPLE_TYPE_UNSET, android.service.notification.ZenPolicy#PEOPLE_TYPE_ANYONE, android.service.notification.ZenPolicy#PEOPLE_TYPE_CONTACTS, android.service.notification.ZenPolicy#PEOPLE_TYPE_STARRED, or android.service.notification.ZenPolicy#PEOPLE_TYPE_NONE
Return
ZenPolicy.Builder This value cannot be null.

allowConversations

Added in API level 30
fun allowConversations(audienceType: Int): ZenPolicy.Builder

Whether to allow conversation notifications (see NotificationChannel#setConversationId(String, String)) that match audienceType to play sounds and visually appear or to intercept them when DND is active.

Parameters
audienceType Int: callers that are allowed to bypass DND Value is android.service.notification.ZenPolicy#CONVERSATION_SENDERS_UNSET, android.service.notification.ZenPolicy#CONVERSATION_SENDERS_ANYONE, android.service.notification.ZenPolicy#CONVERSATION_SENDERS_IMPORTANT, or android.service.notification.ZenPolicy#CONVERSATION_SENDERS_NONE
Return
ZenPolicy.Builder This value cannot be null.

allowEvents

Added in API level 29
fun allowEvents(allow: Boolean): ZenPolicy.Builder

Whether to allow notifications with category Notification#CATEGORY_EVENT to play sounds and visually appear or to intercept them when DND is active.

Return
ZenPolicy.Builder This value cannot be null.

allowMedia

Added in API level 29
fun allowMedia(allow: Boolean): ZenPolicy.Builder

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.

Return
ZenPolicy.Builder This value cannot be null.

allowMessages

Added in API level 29
fun allowMessages(audienceType: Int): ZenPolicy.Builder

Whether to allow notifications with category Notification#CATEGORY_MESSAGE that match audienceType to play sounds and visually appear or to intercept them when DND is active.

Parameters
audienceType Int: message senders that are allowed to bypass DND Value is android.service.notification.ZenPolicy#PEOPLE_TYPE_UNSET, android.service.notification.ZenPolicy#PEOPLE_TYPE_ANYONE, android.service.notification.ZenPolicy#PEOPLE_TYPE_CONTACTS, android.service.notification.ZenPolicy#PEOPLE_TYPE_STARRED, or android.service.notification.ZenPolicy#PEOPLE_TYPE_NONE
Return
ZenPolicy.Builder This value cannot be null.

allowPriorityChannels

fun allowPriorityChannels(allow: Boolean): ZenPolicy.Builder

Set whether priority channels are permitted to break through DND.

Return
ZenPolicy.Builder This value cannot be null.

allowReminders

Added in API level 29
fun allowReminders(allow: Boolean): ZenPolicy.Builder

Whether to allow notifications with category Notification#CATEGORY_REMINDER to play sounds and visually appear or to intercept them when DND is active.

Return
ZenPolicy.Builder This value cannot be null.

allowRepeatCallers

Added in API level 29
fun allowRepeatCallers(allow: Boolean): ZenPolicy.Builder

Whether to allow repeat callers (notifications with category Notification#CATEGORY_CALL that have recently called to play sounds and visually appear.

Return
ZenPolicy.Builder This value cannot be null.

allowSystem

Added in API level 29
fun allowSystem(allow: Boolean): ZenPolicy.Builder

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

Return
ZenPolicy.Builder This value cannot be null.

build

Added in API level 29
fun build(): ZenPolicy

Builds the current ZenPolicy.

Return
ZenPolicy This value cannot be null.

disallowAllSounds

Added in API level 29
fun disallowAllSounds(): ZenPolicy.Builder

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 can bypass DND. If no channels can bypass DND, the ringer stream is also muted.

Return
ZenPolicy.Builder This value cannot be null.

hideAllVisualEffects

Added in API level 29
fun hideAllVisualEffects(): ZenPolicy.Builder

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

Return
ZenPolicy.Builder This value cannot be null.

showAllVisualEffects

Added in API level 29
fun showAllVisualEffects(): ZenPolicy.Builder

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

Return
ZenPolicy.Builder This value cannot be null.

showBadges

Added in API level 29
fun showBadges(show: Boolean): ZenPolicy.Builder

Whether badges from notifications intercepted by DND are allowed on devices that support badging.

Return
ZenPolicy.Builder This value cannot be null.

showFullScreenIntent

Added in API level 29
fun showFullScreenIntent(show: Boolean): ZenPolicy.Builder

Whether full screen intents that are intercepted by DND are shown.

Return
ZenPolicy.Builder This value cannot be null.

showInAmbientDisplay

Added in API level 29
fun showInAmbientDisplay(show: Boolean): ZenPolicy.Builder

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

Return
ZenPolicy.Builder This value cannot be null.

showInNotificationList

Added in API level 29
fun showInNotificationList(show: Boolean): ZenPolicy.Builder

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.

Return
ZenPolicy.Builder This value cannot be null.

showLights

Added in API level 29
fun showLights(show: Boolean): ZenPolicy.Builder

Whether notification lights from notifications intercepted by DND are blocked.

Return
ZenPolicy.Builder This value cannot be null.

showPeeking

Added in API level 29
fun showPeeking(show: Boolean): ZenPolicy.Builder

Whether notifications intercepted by DND are prevented from peeking.

Return
ZenPolicy.Builder This value cannot be null.

showStatusBarIcons

Added in API level 29
fun showStatusBarIcons(show: Boolean): ZenPolicy.Builder

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

Return
ZenPolicy.Builder This value cannot be null.