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 | |
---|---|
Builder() |
Public methods | |
---|---|
ZenPolicy.Builder |
allowAlarms(allow: Boolean) Whether to allow notifications with category |
ZenPolicy.Builder |
Allows all notifications to bypass DND and unmutes all streams. |
ZenPolicy.Builder |
allowCalls(audienceType: Int) Whether to allow notifications with category |
ZenPolicy.Builder |
allowConversations(audienceType: Int) Whether to allow conversation notifications (see |
ZenPolicy.Builder |
allowEvents(allow: Boolean) Whether to allow notifications with category |
ZenPolicy.Builder |
allowMedia(allow: Boolean) 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 |
ZenPolicy.Builder |
allowPriorityChannels(allow: Boolean) Set whether priority channels are permitted to break through DND. |
ZenPolicy.Builder |
allowReminders(allow: Boolean) Whether to allow notifications with category |
ZenPolicy.Builder |
allowRepeatCallers(allow: Boolean) Whether to allow repeat callers (notifications with category |
ZenPolicy.Builder |
allowSystem(allow: Boolean) Whether to allow system sounds to play when DND is active. |
ZenPolicy |
build() 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 |
showBadges(show: Boolean) Whether |
ZenPolicy.Builder |
showFullScreenIntent(show: Boolean) Whether |
ZenPolicy.Builder |
showInAmbientDisplay(show: Boolean) Whether notification intercepted by DND are prevented from appearing on ambient displays on devices that support ambient display. |
ZenPolicy.Builder |
showInNotificationList(show: Boolean) 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 |
showLights(show: Boolean) Whether |
ZenPolicy.Builder |
showPeeking(show: Boolean) Whether notifications intercepted by DND are prevented from peeking. |
ZenPolicy.Builder |
showStatusBarIcons(show: Boolean) Whether notifications intercepted by DND are prevented from appearing in the status bar on devices that support status bars. |
Public constructors
Public methods
allowAlarms
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
fun allowAllSounds(): ZenPolicy.Builder
Allows all notifications to bypass DND and unmutes all streams.
Return | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowCalls
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
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
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
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
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
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
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
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
fun build(): ZenPolicy
Builds the current ZenPolicy.
Return | |
---|---|
ZenPolicy |
This value cannot be null . |
disallowAllSounds
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
fun hideAllVisualEffects(): ZenPolicy.Builder
Disallows notifications intercepted by DND from showing when DND is active.
Return | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showAllVisualEffects
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
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
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
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
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
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
fun showPeeking(show: Boolean): ZenPolicy.Builder
Whether notifications intercepted by DND are prevented from peeking.
Return | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showStatusBarIcons
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 . |