ZenPolicy.Builder
public
static
final
class
ZenPolicy.Builder
extends Object
java.lang.Object | |
↳ | 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(boolean allow)
Whether to allow notifications with category |
ZenPolicy.Builder
|
allowAllSounds()
Allows all notifications to bypass DND and unmutes all streams. |
ZenPolicy.Builder
|
allowCalls(int audienceType)
Whether to allow notifications with category |
ZenPolicy.Builder
|
allowConversations(int audienceType)
Whether to allow conversation notifications
(see |
ZenPolicy.Builder
|
allowEvents(boolean allow)
Whether to allow notifications with category |
ZenPolicy.Builder
|
allowMedia(boolean allow)
Whether to allow media notifications to play sounds and visually appear or to intercept them when DND is active. |
ZenPolicy.Builder
|
allowMessages(int audienceType)
Whether to allow notifications with category |
ZenPolicy.Builder
|
allowPriorityChannels(boolean allow)
Set whether priority channels are permitted to break through DND. |
ZenPolicy.Builder
|
allowReminders(boolean allow)
Whether to allow notifications with category |
ZenPolicy.Builder
|
allowRepeatCallers(boolean allow)
Whether to allow repeat callers (notifications with category
|
ZenPolicy.Builder
|
allowSystem(boolean allow)
Whether to allow system sounds to play when DND is active. |
ZenPolicy
|
build()
Builds the current ZenPolicy. |
ZenPolicy.Builder
|
disallowAllSounds()
Intercepts all notifications and prevents them from playing sounds when DND is active. |
ZenPolicy.Builder
|
hideAllVisualEffects()
Disallows notifications intercepted by DND from showing when DND is active. |
ZenPolicy.Builder
|
showAllVisualEffects()
Allows notifications intercepted by DND to show on all surfaces when DND is active. |
ZenPolicy.Builder
|
showBadges(boolean show)
Whether |
ZenPolicy.Builder
|
showFullScreenIntent(boolean show)
Whether |
ZenPolicy.Builder
|
showInAmbientDisplay(boolean show)
Whether notification intercepted by DND are prevented from appearing on ambient displays on devices that support ambient display. |
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. |
ZenPolicy.Builder
|
showLights(boolean show)
Whether |
ZenPolicy.Builder
|
showPeeking(boolean show)
Whether notifications intercepted by DND are prevented from peeking. |
ZenPolicy.Builder
|
showStatusBarIcons(boolean show)
Whether notifications intercepted by DND are prevented from appearing in the status bar on devices that support status bars. |
Inherited methods | |
---|---|
Public constructors
Public methods
allowAlarms
public ZenPolicy.Builder allowAlarms (boolean allow)
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.
Parameters | |
---|---|
allow |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowAllSounds
public ZenPolicy.Builder allowAllSounds ()
Allows all notifications to bypass DND and unmutes all streams.
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowCalls
public ZenPolicy.Builder allowCalls (int audienceType)
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 ZenPolicy.PEOPLE_TYPE_UNSET , ZenPolicy.PEOPLE_TYPE_ANYONE , ZenPolicy.PEOPLE_TYPE_CONTACTS , ZenPolicy.PEOPLE_TYPE_STARRED , or ZenPolicy.PEOPLE_TYPE_NONE |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowConversations
public ZenPolicy.Builder allowConversations (int audienceType)
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 ZenPolicy.CONVERSATION_SENDERS_UNSET , ZenPolicy.CONVERSATION_SENDERS_ANYONE , ZenPolicy.CONVERSATION_SENDERS_IMPORTANT , or ZenPolicy.CONVERSATION_SENDERS_NONE |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowEvents
public ZenPolicy.Builder allowEvents (boolean allow)
Whether to allow notifications with category Notification.CATEGORY_EVENT
to play sounds and visually appear or to intercept them when DND is active.
Parameters | |
---|---|
allow |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowMedia
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.
Parameters | |
---|---|
allow |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowMessages
public ZenPolicy.Builder allowMessages (int audienceType)
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 ZenPolicy.PEOPLE_TYPE_UNSET , ZenPolicy.PEOPLE_TYPE_ANYONE , ZenPolicy.PEOPLE_TYPE_CONTACTS , ZenPolicy.PEOPLE_TYPE_STARRED , or ZenPolicy.PEOPLE_TYPE_NONE |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowPriorityChannels
public ZenPolicy.Builder allowPriorityChannels (boolean allow)
Set whether priority channels are permitted to break through DND.
Parameters | |
---|---|
allow |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowReminders
public ZenPolicy.Builder allowReminders (boolean allow)
Whether to allow notifications with category Notification.CATEGORY_REMINDER
to play sounds and visually appear or to intercept them when DND is active.
Parameters | |
---|---|
allow |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowRepeatCallers
public ZenPolicy.Builder allowRepeatCallers (boolean allow)
Whether to allow repeat callers (notifications with category
Notification.CATEGORY_CALL
that have recently called
to play sounds and visually appear.
Parameters | |
---|---|
allow |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
allowSystem
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.
Parameters | |
---|---|
allow |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
build
public ZenPolicy build ()
Builds the current ZenPolicy.
Returns | |
---|---|
ZenPolicy |
This value cannot be null . |
disallowAllSounds
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
can bypass DND
. If no channels can bypass DND,
the ringer stream is also muted.
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
hideAllVisualEffects
public ZenPolicy.Builder hideAllVisualEffects ()
Disallows notifications intercepted by DND from showing when DND is active.
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showAllVisualEffects
public ZenPolicy.Builder showAllVisualEffects ()
Allows notifications intercepted by DND to show on all surfaces when DND is active.
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showBadges
public ZenPolicy.Builder showBadges (boolean show)
Whether badges
from
notifications intercepted by DND are allowed on devices that support badging.
Parameters | |
---|---|
show |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showFullScreenIntent
public ZenPolicy.Builder showFullScreenIntent (boolean show)
Whether full screen intents
that are intercepted
by DND are shown.
Parameters | |
---|---|
show |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showInAmbientDisplay
public ZenPolicy.Builder showInAmbientDisplay (boolean show)
Whether notification intercepted by DND are prevented from appearing on ambient displays on devices that support ambient display.
Parameters | |
---|---|
show |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showInNotificationList
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.
Parameters | |
---|---|
show |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showLights
public ZenPolicy.Builder showLights (boolean show)
Whether notification lights
from
notifications intercepted by DND are blocked.
Parameters | |
---|---|
show |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showPeeking
public ZenPolicy.Builder showPeeking (boolean show)
Whether notifications intercepted by DND are prevented from peeking.
Parameters | |
---|---|
show |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |
showStatusBarIcons
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.
Parameters | |
---|---|
show |
boolean |
Returns | |
---|---|
ZenPolicy.Builder |
This value cannot be null . |