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 |
static Int |
Whether |
static Int |
Whether |
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 | |
---|---|
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 |
Indicates whether some other object is "equal to" this one. |
open Int |
hashCode() |
open static String! |
priorityCategoriesToString(priorityCategories: Int) |
open static String! |
prioritySendersToString(prioritySenders: Int) |
open static String! |
suppressedEffectsToString(effects: Int) |
open String |
toString() |
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
static val CONVERSATION_SENDERS_ANYONE: Int
Used to indicate all conversations can bypass dnd.
Value: 1
CONVERSATION_SENDERS_IMPORTANT
static val CONVERSATION_SENDERS_IMPORTANT: Int
Used to indicate important conversations can bypass dnd.
Value: 2
CONVERSATION_SENDERS_NONE
static val CONVERSATION_SENDERS_NONE: Int
Used to indicate no conversations can bypass dnd.
Value: 3
PRIORITY_CATEGORY_ALARMS
static val PRIORITY_CATEGORY_ALARMS: Int
Alarms are prioritized
Value: 32
PRIORITY_CATEGORY_CALLS
static val PRIORITY_CATEGORY_CALLS: Int
Calls are prioritized.
Value: 8
PRIORITY_CATEGORY_CONVERSATIONS
static val PRIORITY_CATEGORY_CONVERSATIONS: Int
Conversations are allowed through DND.
Value: 256
PRIORITY_CATEGORY_EVENTS
static val PRIORITY_CATEGORY_EVENTS: Int
Event notifications are prioritized.
Value: 2
PRIORITY_CATEGORY_MEDIA
static val PRIORITY_CATEGORY_MEDIA: Int
Media, game, voice navigation are prioritized
Value: 64
PRIORITY_CATEGORY_MESSAGES
static val PRIORITY_CATEGORY_MESSAGES: Int
Message notifications are prioritized.
Value: 4
PRIORITY_CATEGORY_REMINDERS
static val PRIORITY_CATEGORY_REMINDERS: Int
Reminder notifications are prioritized.
Value: 1
PRIORITY_CATEGORY_REPEAT_CALLERS
static val PRIORITY_CATEGORY_REPEAT_CALLERS: Int
Calls from repeat callers are prioritized.
Value: 16
PRIORITY_CATEGORY_SYSTEM
static val PRIORITY_CATEGORY_SYSTEM: Int
System (catch-all for non-never suppressible sounds) are prioritized
Value: 128
PRIORITY_SENDERS_ANY
static val PRIORITY_SENDERS_ANY: Int
Any sender is prioritized.
Value: 0
PRIORITY_SENDERS_CONTACTS
static val PRIORITY_SENDERS_CONTACTS: Int
Saved contacts are prioritized.
Value: 1
PRIORITY_SENDERS_STARRED
static val PRIORITY_SENDERS_STARRED: Int
Only starred contacts are prioritized.
Value: 2
SUPPRESSED_EFFECT_AMBIENT
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
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
static val SUPPRESSED_EFFECT_FULL_SCREEN_INTENT: Int
Whether full screen intents
from notifications intercepted by DND are blocked.
Value: 4
SUPPRESSED_EFFECT_LIGHTS
static val SUPPRESSED_EFFECT_LIGHTS: Int
Whether notification lights
from notifications intercepted by DND are blocked.
Value: 8
SUPPRESSED_EFFECT_NOTIFICATION_LIST
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
static val SUPPRESSED_EFFECT_PEEK: Int
Whether notifications intercepted by DND are prevented from peeking.
Value: 16
SUPPRESSED_EFFECT_SCREEN_OFF
static valSUPPRESSED_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
static valSUPPRESSED_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
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
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
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
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
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
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 returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
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
open fun hashCode(): Int
Return | |
---|---|
Int |
a hash code value for this object. |
priorityCategoriesToString
open static fun priorityCategoriesToString(priorityCategories: Int): String!
prioritySendersToString
open static fun prioritySendersToString(prioritySenders: Int): String!
suppressedEffectsToString
open static fun suppressedEffectsToString(effects: Int): String!
toString
open fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
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
priorityCallSenders
val priorityCallSenders: Int
Notification senders to prioritize for calls. One of: PRIORITY_SENDERS_ANY, PRIORITY_SENDERS_CONTACTS, PRIORITY_SENDERS_STARRED
Value is android.app.NotificationManager.Policy#PRIORITY_SENDERS_ANY
, android.app.NotificationManager.Policy#PRIORITY_SENDERS_CONTACTS
, or android.app.NotificationManager.Policy#PRIORITY_SENDERS_STARRED
priorityCategories
val priorityCategories: Int
Notification categories to prioritize. Bitmask of PRIORITY_CATEGORY_* constants.
priorityConversationSenders
val priorityConversationSenders: Int
Notification senders to prioritize for conversations. One of: CONVERSATION_SENDERS_NONE
, CONVERSATION_SENDERS_IMPORTANT
, CONVERSATION_SENDERS_ANYONE
.
Value is android.app.NotificationManager.Policy#CONVERSATION_SENDERS_ANYONE
, android.app.NotificationManager.Policy#CONVERSATION_SENDERS_IMPORTANT
, or android.app.NotificationManager.Policy#CONVERSATION_SENDERS_NONE
priorityMessageSenders
val priorityMessageSenders: Int
Notification senders to prioritize for messages. One of: PRIORITY_SENDERS_ANY, PRIORITY_SENDERS_CONTACTS, PRIORITY_SENDERS_STARRED
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
val suppressedVisualEffects: Int
Visual effects to suppress for a notification that is filtered by Do Not Disturb mode. Bitmask of SUPPRESSED_EFFECT_* constants.