Added in API level 29

ZenPolicy


class ZenPolicy : Parcelable
kotlin.Any
   ↳ android.service.notification.ZenPolicy

ZenPolicy determines whether to allow certain notifications and their corresponding sounds to play when a device is in Do Not Disturb mode. ZenPolicy also dictates the visual effects of notifications that are intercepted when a device is in Do Not Disturb mode.

Summary

Nested classes

Builder class for ZenPolicy objects.

Constants
static Int

Used to indicate all conversations can bypass dnd.

static Int

Used to indicate important conversations can bypass dnd.

static Int

Used to indicate no conversations can bypass dnd.

static Int

Used to indicate no preference for the type of conversations that can bypass dnd.

static Int

Used to indicate all calls or messages can bypass dnd.

static Int

Used to indicate calls or messages from contacts can bypass dnd.

static Int

Used to indicate no calls or messages can bypass dnd.

static Int

Used to indicate calls or messages from starred contacts can bypass dnd.

static Int

Used to indicate no preference for the type of people that can bypass dnd for either calls or messages.

static Int

Indicates a type of sound or visual effect is allowed to play/show when DND is active.

static Int

Indicates a type of sound or visual effect is not allowed to play/show when DND is active.

static Int

Indicates no preference for whether a type of sound or visual effect is or isn't allowed to play/show when DND is active.

Inherited constants
Public methods
Int

Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

Int

Callers that can bypass DND.

Int

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

Int

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

Int

Whether this policy wants to allow conversation notifications (see NotificationChannel#getConversationId()) to play sounds and visually appear or to intercept them when DND is active.

Int

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

Int

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

Int

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

Int

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

Int

Whether this policy wants to allow repeat callers (notifications with category Notification#CATEGORY_CALL that have recently called) to play sounds and visually appear or to intercept them when DND is active.

Int

Whether this policy wants to allow system sounds when DND is active.

Int

Whether this policy allows channels marked as NotificationChannel#canBypassDnd() to bypass DND.

Int

Conversation type that can bypass DND.

Int

Message senders that can bypass DND.

Int

Whether this policy allows notifications intercepted by DND from appearing on ambient displays on devices that support ambient display.

Int

Whether this policy allows badges from notifications intercepted by DND on devices that support badging.

Int

Whether this policy allows full screen intents from notifications intercepted by DND.

Int

Whether this policy allows lights from notifications intercepted by DND.

Int

Whether this policy allows notifications intercepted by DND from appearing in notification list views like the notification shade or lockscreen on devices that support those views.

Int

Whether this policy allows peeking from notifications intercepted by DND.

Int

Whether this policy allows notifications intercepted by DND from appearing in the status bar on devices that support status bars.

Int

String

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<ZenPolicy!>

Constants

CONVERSATION_SENDERS_ANYONE

Added in API level 30
static val CONVERSATION_SENDERS_ANYONE: Int

Used to indicate all conversations can bypass dnd.

Value: 1

CONVERSATION_SENDERS_IMPORTANT

Added in API level 30
static val CONVERSATION_SENDERS_IMPORTANT: Int

Used to indicate important conversations can bypass dnd.

Value: 2

CONVERSATION_SENDERS_NONE

Added in API level 30
static val CONVERSATION_SENDERS_NONE: Int

Used to indicate no conversations can bypass dnd.

Value: 3

CONVERSATION_SENDERS_UNSET

Added in API level 30
static val CONVERSATION_SENDERS_UNSET: Int

Used to indicate no preference for the type of conversations that can bypass dnd.

Value: 0

PEOPLE_TYPE_ANYONE

Added in API level 29
static val PEOPLE_TYPE_ANYONE: Int

Used to indicate all calls or messages can bypass dnd.

Value: 1

PEOPLE_TYPE_CONTACTS

Added in API level 29
static val PEOPLE_TYPE_CONTACTS: Int

Used to indicate calls or messages from contacts can bypass dnd.

Value: 2

PEOPLE_TYPE_NONE

Added in API level 29
static val PEOPLE_TYPE_NONE: Int

Used to indicate no calls or messages can bypass dnd.

Value: 4

PEOPLE_TYPE_STARRED

Added in API level 29
static val PEOPLE_TYPE_STARRED: Int

Used to indicate calls or messages from starred contacts can bypass dnd.

Value: 3

PEOPLE_TYPE_UNSET

Added in API level 29
static val PEOPLE_TYPE_UNSET: Int

Used to indicate no preference for the type of people that can bypass dnd for either calls or messages.

Value: 0

STATE_ALLOW

Added in API level 29
static val STATE_ALLOW: Int

Indicates a type of sound or visual effect is allowed to play/show when DND is active.

Value: 1

STATE_DISALLOW

Added in API level 29
static val STATE_DISALLOW: Int

Indicates a type of sound or visual effect is not allowed to play/show when DND is active.

Value: 2

STATE_UNSET

Added in API level 29
static val STATE_UNSET: Int

Indicates no preference for whether a type of sound or visual effect is or isn't allowed to play/show when DND is active. Will default to the current set policy.

Value: 0

Public methods

describeContents

Added in API level 29
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 29
fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj the reference object with which to compare.
o This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getPriorityCategoryAlarms

Added in API level 29
fun getPriorityCategoryAlarms(): Int

Whether this policy wants to allow notifications with category Notification#CATEGORY_ALARM to play sounds and visually appear or to intercept them when DND is active. When alarms are disallowed, the alarm stream will be muted when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityCategoryCalls

Added in API level 29
fun getPriorityCategoryCalls(): Int

Whether this policy wants to allow notifications with category Notification#CATEGORY_CALL to play sounds and visually appear or to intercept them when DND is active. Types of callers that are allowed are specified by getPriorityCallSenders().

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityCategoryConversations

Added in API level 30
fun getPriorityCategoryConversations(): Int

Whether this policy wants to allow conversation notifications (see NotificationChannel#getConversationId()) to play sounds and visually appear or to intercept them when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityCategoryEvents

Added in API level 29
fun getPriorityCategoryEvents(): Int

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

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityCategoryMedia

Added in API level 29
fun getPriorityCategoryMedia(): Int

Whether this policy wants to allow media notifications to play sounds and visually appear or to intercept them when DND is active. When media is disallowed, the media stream will be muted when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityCategoryMessages

Added in API level 29
fun getPriorityCategoryMessages(): Int

Whether this policy wants to allow notifications with category Notification#CATEGORY_MESSAGE to play sounds and visually appear or to intercept them when DND is active. Types of message senders that are allowed are specified by getPriorityMessageSenders.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityCategoryReminders

Added in API level 29
fun getPriorityCategoryReminders(): Int

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

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityCategoryRepeatCallers

Added in API level 29
fun getPriorityCategoryRepeatCallers(): Int

Whether this policy wants to allow repeat callers (notifications with category Notification#CATEGORY_CALL that have recently called) to play sounds and visually appear or to intercept them when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityCategorySystem

Added in API level 29
fun getPriorityCategorySystem(): Int

Whether this policy wants to allow system sounds when DND is active. When system is STATE_DISALLOW, the system stream will be muted when DND is active.

Return
Int STATE_UNSET, STATE_ALLOW or STATE_DISALLOW Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getPriorityChannelsAllowed

Added in API level 35
fun getPriorityChannelsAllowed(): Int

Whether this policy allows channels marked as NotificationChannel#canBypassDnd() to bypass DND. If STATE_ALLOW, these channels may bypass; if STATE_DISALLOW, then even notifications from channels with NotificationChannel#canBypassDnd() will be intercepted.

Return
Int Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getVisualEffectAmbient

Added in API level 29
fun getVisualEffectAmbient(): Int

Whether this policy allows notifications intercepted by DND from appearing on ambient displays on devices that support ambient display.

Return
Int Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getVisualEffectBadge

Added in API level 29
fun getVisualEffectBadge(): Int

Whether this policy allows badges from notifications intercepted by DND on devices that support badging.

Return
Int Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getVisualEffectFullScreenIntent

Added in API level 29
fun getVisualEffectFullScreenIntent(): Int

Whether this policy allows full screen intents from notifications intercepted by DND.

Return
Int Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getVisualEffectLights

Added in API level 29
fun getVisualEffectLights(): Int

Whether this policy allows lights from notifications intercepted by DND.

Return
Int Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getVisualEffectNotificationList

Added in API level 29
fun getVisualEffectNotificationList(): Int

Whether this policy allows notifications intercepted by DND from appearing in notification list views like the notification shade or lockscreen on devices that support those views.

Return
Int Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getVisualEffectPeek

Added in API level 29
fun getVisualEffectPeek(): Int

Whether this policy allows peeking from notifications intercepted by DND.

Return
Int Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

getVisualEffectStatusBar

Added in API level 29
fun getVisualEffectStatusBar(): Int

Whether this policy allows notifications intercepted by DND from appearing in the status bar on devices that support status bars.

Return
Int Value is android.service.notification.ZenPolicy#STATE_UNSET, android.service.notification.ZenPolicy#STATE_ALLOW, or android.service.notification.ZenPolicy#STATE_DISALLOW

hashCode

Added in API level 29
fun hashCode(): Int
Return
Int a hash code value for this object.

toString

Added in API level 29
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 29
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 29
static val CREATOR: Parcelable.Creator<ZenPolicy!>