Added in API level 23

Policy

open class Policy : Parcelable
kotlin.Any
   ↳ android.app.NotificationManager.Policy

Notification policy configuration. Represents user-preferences for notification filtering.

Summary

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

Alarms are prioritized

static Int

Calls are prioritized.

static Int

Conversations are allowed through DND.

static Int

Event notifications are prioritized.

static Int

Media, game, voice navigation are prioritized

static Int

Message notifications are prioritized.

static Int

Reminder notifications are prioritized.

static Int

Calls from repeat callers are prioritized.

static Int

System (catch-all for non-never suppressible sounds) are prioritized

static Int

Any sender is prioritized.

static Int

Saved contacts are prioritized.

static Int

Only starred contacts are prioritized.

static Int

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

static Int

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

static Int

Whether full screen intents from notifications intercepted by DND are blocked.

static Int

Whether notification lights from notifications intercepted by DND are blocked.

static Int

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.

static Int

Whether notifications intercepted by DND are prevented from peeking.

static Int

Whether notifications suppressed by DND should not interrupt visually (e.g. with notification lights or by turning the screen on) when the screen is off.

static Int

Whether notifications suppressed by DND should not interrupt visually when the screen is on (e.g. by peeking onto the screen).

static Int

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

Inherited constants
Public constructors
Policy(priorityCategories: Int, priorityCallSenders: Int, priorityMessageSenders: Int)

Constructs a policy for Do Not Disturb priority mode behavior.

Policy(priorityCategories: Int, priorityCallSenders: Int, priorityMessageSenders: Int, suppressedVisualEffects: Int)

Constructs a policy for Do Not Disturb priority mode behavior.

Policy(priorityCategories: Int, priorityCallSenders: Int, priorityMessageSenders: Int, suppressedVisualEffects: Int, priorityConversationSenders: Int)

Constructs a policy for Do Not Disturb priority mode behavior.

Public methods
open Int

open Boolean
equals(other: Any?)

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

open Int

open static String!
priorityCategoriesToString(priorityCategories: Int)

open static String!
prioritySendersToString(prioritySenders: Int)

open static String!

open String

open Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<NotificationManager.Policy!>

Int

Notification senders to prioritize for calls.

Int

Notification categories to prioritize.

Int

Notification senders to prioritize for conversations.

Int

Notification senders to prioritize for messages.

Int

Visual effects to suppress for a notification that is filtered by Do Not Disturb mode.

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

PRIORITY_CATEGORY_ALARMS

Added in API level 28
static val PRIORITY_CATEGORY_ALARMS: Int

Alarms are prioritized

Value: 32

PRIORITY_CATEGORY_CALLS

Added in API level 23
static val PRIORITY_CATEGORY_CALLS: Int

Calls are prioritized.

Value: 8

PRIORITY_CATEGORY_CONVERSATIONS

Added in API level 30
static val PRIORITY_CATEGORY_CONVERSATIONS: Int

Conversations are allowed through DND.

Value: 256

PRIORITY_CATEGORY_EVENTS

Added in API level 23
static val PRIORITY_CATEGORY_EVENTS: Int

Event notifications are prioritized.

Value: 2

PRIORITY_CATEGORY_MEDIA

Added in API level 28
static val PRIORITY_CATEGORY_MEDIA: Int

Media, game, voice navigation are prioritized

Value: 64

PRIORITY_CATEGORY_MESSAGES

Added in API level 23
static val PRIORITY_CATEGORY_MESSAGES: Int

Message notifications are prioritized.

Value: 4

PRIORITY_CATEGORY_REMINDERS

Added in API level 23
static val PRIORITY_CATEGORY_REMINDERS: Int

Reminder notifications are prioritized.

Value: 1

PRIORITY_CATEGORY_REPEAT_CALLERS

Added in API level 23
static val PRIORITY_CATEGORY_REPEAT_CALLERS: Int

Calls from repeat callers are prioritized.

Value: 16

PRIORITY_CATEGORY_SYSTEM

Added in API level 28
static val PRIORITY_CATEGORY_SYSTEM: Int

System (catch-all for non-never suppressible sounds) are prioritized

Value: 128

PRIORITY_SENDERS_ANY

Added in API level 23
static val PRIORITY_SENDERS_ANY: Int

Any sender is prioritized.

Value: 0

PRIORITY_SENDERS_CONTACTS

Added in API level 23
static val PRIORITY_SENDERS_CONTACTS: Int

Saved contacts are prioritized.

Value: 1

PRIORITY_SENDERS_STARRED

Added in API level 23
static val PRIORITY_SENDERS_STARRED: Int

Only starred contacts are prioritized.

Value: 2

SUPPRESSED_EFFECT_AMBIENT

Added in API level 28
static val SUPPRESSED_EFFECT_AMBIENT: Int

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

Value: 128

SUPPRESSED_EFFECT_BADGE

Added in API level 28
static val SUPPRESSED_EFFECT_BADGE: Int

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

Value: 64

SUPPRESSED_EFFECT_FULL_SCREEN_INTENT

Added in API level 28
static val SUPPRESSED_EFFECT_FULL_SCREEN_INTENT: Int

Whether full screen intents from notifications intercepted by DND are blocked.

Value: 4

SUPPRESSED_EFFECT_LIGHTS

Added in API level 28
static val SUPPRESSED_EFFECT_LIGHTS: Int

Whether notification lights from notifications intercepted by DND are blocked.

Value: 8

SUPPRESSED_EFFECT_NOTIFICATION_LIST

Added in API level 28
static val SUPPRESSED_EFFECT_NOTIFICATION_LIST: Int

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.

Value: 256

SUPPRESSED_EFFECT_PEEK

Added in API level 28
static val SUPPRESSED_EFFECT_PEEK: Int

Whether notifications intercepted by DND are prevented from peeking.

Value: 16

SUPPRESSED_EFFECT_SCREEN_OFF

Added in API level 24
Deprecated in API level 28
static val SUPPRESSED_EFFECT_SCREEN_OFF: Int

Deprecated: use SUPPRESSED_EFFECT_FULL_SCREEN_INTENT and SUPPRESSED_EFFECT_AMBIENT and SUPPRESSED_EFFECT_LIGHTS individually.

Whether notifications suppressed by DND should not interrupt visually (e.g. with notification lights or by turning the screen on) when the screen is off.

Value: 1

SUPPRESSED_EFFECT_SCREEN_ON

Added in API level 24
Deprecated in API level 28
static val SUPPRESSED_EFFECT_SCREEN_ON: Int

Deprecated: use SUPPRESSED_EFFECT_PEEK.

Whether notifications suppressed by DND should not interrupt visually when the screen is on (e.g. by peeking onto the screen).

Value: 2

SUPPRESSED_EFFECT_STATUS_BAR

Added in API level 28
static val SUPPRESSED_EFFECT_STATUS_BAR: Int

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

Value: 32

Public constructors

Policy

Added in API level 23
Policy(
    priorityCategories: Int,
    priorityCallSenders: Int,
    priorityMessageSenders: Int)

Constructs a policy for Do Not Disturb priority mode behavior.

Apps that target API levels below Build.VERSION_CODES#P cannot change user-designated values to allow or disallow Policy#PRIORITY_CATEGORY_ALARMS, Policy#PRIORITY_CATEGORY_SYSTEM, and Policy#PRIORITY_CATEGORY_MEDIA from bypassing dnd.

Parameters
priorityCategories Int: bitmask of categories of notifications that can bypass DND.
priorityCallSenders Int: which callers can bypass DND.
priorityMessageSenders Int: which message senders can bypass DND.

Policy

Added in API level 23
Policy(
    priorityCategories: Int,
    priorityCallSenders: Int,
    priorityMessageSenders: Int,
    suppressedVisualEffects: Int)

Constructs a policy for Do Not Disturb priority mode behavior.

Apps that target API levels below Build.VERSION_CODES#R cannot change user-designated values to allow or disallow Policy#PRIORITY_CATEGORY_CONVERSATIONS, from bypassing dnd.

Additionally, apps that target API levels below Build.VERSION_CODES#P can only modify the SUPPRESSED_EFFECT_SCREEN_ON and SUPPRESSED_EFFECT_SCREEN_OFF bits of the suppressed visual effects field. All other suppressed effects will be ignored and reconstituted from the screen on and screen off values.

Apps that target Build.VERSION_CODES#P or above can set any suppressed visual effects. However, if any suppressed effects > SUPPRESSED_EFFECT_SCREEN_ON are set, SUPPRESSED_EFFECT_SCREEN_ON and SUPPRESSED_EFFECT_SCREEN_OFF will be ignored and reconstituted from the more specific suppressed visual effect bits. Apps should migrate to targeting specific effects instead of the deprecated SUPPRESSED_EFFECT_SCREEN_ON and SUPPRESSED_EFFECT_SCREEN_OFF effects.

Parameters
priorityCategories Int: bitmask of categories of notifications that can bypass DND.
priorityCallSenders Int: which callers can bypass DND.
priorityMessageSenders Int: which message senders can bypass DND.
suppressedVisualEffects Int: which visual interruptions should be suppressed from notifications that are filtered by DND.

Policy

Added in API level 23
Policy(
    priorityCategories: Int,
    priorityCallSenders: Int,
    priorityMessageSenders: Int,
    suppressedVisualEffects: Int,
    priorityConversationSenders: Int)

Constructs a policy for Do Not Disturb priority mode behavior.

Apps that target API levels below Build.VERSION_CODES#P cannot change user-designated values to allow or disallow Policy#PRIORITY_CATEGORY_CONVERSATIONS from bypassing dnd. If you do need to change them, use a ZenPolicy associated with an AutomaticZenRule instead of changing the global setting.

Apps that target API levels below Build.VERSION_CODES#P cannot change user-designated values to allow or disallow Policy#PRIORITY_CATEGORY_ALARMS, Policy#PRIORITY_CATEGORY_SYSTEM, and Policy#PRIORITY_CATEGORY_MEDIA from bypassing dnd.

Additionally, apps that target API levels below Build.VERSION_CODES#P can only modify the SUPPRESSED_EFFECT_SCREEN_ON and SUPPRESSED_EFFECT_SCREEN_OFF bits of the suppressed visual effects field. All other suppressed effects will be ignored and reconstituted from the screen on and screen off values.

Apps that target Build.VERSION_CODES#P or above can set any suppressed visual effects. However, if any suppressed effects > SUPPRESSED_EFFECT_SCREEN_ON are set, SUPPRESSED_EFFECT_SCREEN_ON and SUPPRESSED_EFFECT_SCREEN_OFF will be ignored and reconstituted from the more specific suppressed visual effect bits. Apps should migrate to targeting specific effects instead of the deprecated SUPPRESSED_EFFECT_SCREEN_ON and SUPPRESSED_EFFECT_SCREEN_OFF effects.

Parameters
priorityCategories Int: bitmask of categories of notifications that can bypass DND.
priorityCallSenders Int: which callers can bypass DND. Value is android.app.NotificationManager.Policy#PRIORITY_SENDERS_ANY, android.app.NotificationManager.Policy#PRIORITY_SENDERS_CONTACTS, or android.app.NotificationManager.Policy#PRIORITY_SENDERS_STARRED
priorityMessageSenders Int: which message senders can bypass DND. Value is android.app.NotificationManager.Policy#PRIORITY_SENDERS_ANY, android.app.NotificationManager.Policy#PRIORITY_SENDERS_CONTACTS, or android.app.NotificationManager.Policy#PRIORITY_SENDERS_STARRED
suppressedVisualEffects Int: which visual interruptions should be suppressed from notifications that are filtered by DND.
priorityConversationSenders Int: Value is android.app.NotificationManager.Policy#CONVERSATION_SENDERS_ANYONE, android.app.NotificationManager.Policy#CONVERSATION_SENDERS_IMPORTANT, or android.app.NotificationManager.Policy#CONVERSATION_SENDERS_NONE

Public methods

describeContents

Added in API level 23
open 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 23
open 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.

hashCode

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

priorityCategoriesToString

Added in API level 23
open static fun priorityCategoriesToString(priorityCategories: Int): String!

prioritySendersToString

Added in API level 23
open static fun prioritySendersToString(prioritySenders: Int): String!

suppressedEffectsToString

Added in API level 24
open static fun suppressedEffectsToString(effects: Int): String!

toString

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

writeToParcel

Added in API level 23
open 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 23
static val CREATOR: Parcelable.Creator<NotificationManager.Policy!>

priorityCallSenders

Added in API level 23
val priorityCallSenders: Int

Notification senders to prioritize for calls. One of: PRIORITY_SENDERS_ANY, PRIORITY_SENDERS_CONTACTS, PRIORITY_SENDERS_STARRED

priorityCategories

Added in API level 23
val priorityCategories: Int

Notification categories to prioritize. Bitmask of PRIORITY_CATEGORY_* constants.

priorityConversationSenders

Added in API level 30
val priorityConversationSenders: Int

Notification senders to prioritize for conversations. One of: CONVERSATION_SENDERS_NONE, CONVERSATION_SENDERS_IMPORTANT, CONVERSATION_SENDERS_ANYONE.

priorityMessageSenders

Added in API level 23
val priorityMessageSenders: Int

Notification senders to prioritize for messages. One of: PRIORITY_SENDERS_ANY, PRIORITY_SENDERS_CONTACTS, PRIORITY_SENDERS_STARRED

suppressedVisualEffects

Added in API level 24
val suppressedVisualEffects: Int

Visual effects to suppress for a notification that is filtered by Do Not Disturb mode. Bitmask of SUPPRESSED_EFFECT_* constants.