Most visited

Recently visited

Added in API level 23

NotificationManager.Policy

public static class NotificationManager.Policy
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.NotificationManager.Policy


通知政策配置。 代表通知筛选的用户首选项。

Summary

Constants

int PRIORITY_CATEGORY_CALLS

通话优先。

int PRIORITY_CATEGORY_EVENTS

事件通知优先。

int PRIORITY_CATEGORY_MESSAGES

消息通知优先。

int PRIORITY_CATEGORY_REMINDERS

提醒通知优先。

int PRIORITY_CATEGORY_REPEAT_CALLERS

重复呼叫者的呼叫优先。

int PRIORITY_SENDERS_ANY

任何发件人优先。

int PRIORITY_SENDERS_CONTACTS

保存的联系人优先。

int PRIORITY_SENDERS_STARRED

只有加星标的联系人优先。

int SUPPRESSED_EFFECT_SCREEN_OFF

DND是否应该阻止通知被视觉中断(例如,

int SUPPRESSED_EFFECT_SCREEN_ON

当屏幕开启时,是否不应当通过DND抑制通知(例如,

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<NotificationManager.Policy> CREATOR

public final int priorityCallSenders

通知发件人优先处理呼叫。

public final int priorityCategories

通知类别优先。

public final int priorityMessageSenders

通知发件人优先处理消息。

public final int suppressedVisualEffects

视觉效果可以抑制通过“请勿打扰”模式过滤的通知。

Public constructors

NotificationManager.Policy(int priorityCategories, int priorityCallSenders, int priorityMessageSenders)

构建“请勿打扰”优先模式行为的策略。

NotificationManager.Policy(int priorityCategories, int priorityCallSenders, int priorityMessageSenders, int suppressedVisualEffects)

构建“请勿打扰”优先模式行为的策略。

Public methods

int describeContents()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。

boolean equals(Object o)

指示其他某个对象是否“等于”这一个。

int hashCode()

返回对象的哈希码值。

static String priorityCategoriesToString(int priorityCategories)
static String prioritySendersToString(int prioritySenders)
static String suppressedEffectsToString(int effects)
String toString()

返回对象的字符串表示形式。

void writeToParcel(Parcel dest, int flags)

将此对象平铺到一个包裹中。

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

PRIORITY_CATEGORY_CALLS

Added in API level 23
int PRIORITY_CATEGORY_CALLS

通话优先。

常量值:8(0x00000008)

PRIORITY_CATEGORY_EVENTS

Added in API level 23
int PRIORITY_CATEGORY_EVENTS

事件通知优先。

常量值:2(0x00000002)

PRIORITY_CATEGORY_MESSAGES

Added in API level 23
int PRIORITY_CATEGORY_MESSAGES

消息通知优先。

常量值:4(0x00000004)

PRIORITY_CATEGORY_REMINDERS

Added in API level 23
int PRIORITY_CATEGORY_REMINDERS

提醒通知优先。

常数值:1(0x00000001)

PRIORITY_CATEGORY_REPEAT_CALLERS

Added in API level 23
int PRIORITY_CATEGORY_REPEAT_CALLERS

重复呼叫者的呼叫优先。

常量值:16(0x00000010)

PRIORITY_SENDERS_ANY

Added in API level 23
int PRIORITY_SENDERS_ANY

任何发件人优先。

常量值:0(0x00000000)

PRIORITY_SENDERS_CONTACTS

Added in API level 23
int PRIORITY_SENDERS_CONTACTS

保存的联系人优先。

常数值:1(0x00000001)

PRIORITY_SENDERS_STARRED

Added in API level 23
int PRIORITY_SENDERS_STARRED

只有加星标的联系人优先。

常量值:2(0x00000002)

SUPPRESSED_EFFECT_SCREEN_OFF

Added in API level 24
int SUPPRESSED_EFFECT_SCREEN_OFF

当屏幕关闭时,是否不应通过DND屏蔽通知(例如,通知灯或打开屏幕)。

常数值:1(0x00000001)

SUPPRESSED_EFFECT_SCREEN_ON

Added in API level 24
int SUPPRESSED_EFFECT_SCREEN_ON

当屏幕打开时(例如,通过窥视屏幕),是否不应当通过免打扰抑制通知。

常量值:2(0x00000002)

Fields

CREATOR

Added in API level 23
Creator<NotificationManager.Policy> CREATOR

priorityCallSenders

Added in API level 23
int priorityCallSenders

通知发件人优先处理呼叫。 其中一个:PRIORITY_SENDERS_ANY,PRIORITY_SENDERS_CONTACTS,PRIORITY_SENDERS_STARRED

priorityCategories

Added in API level 23
int priorityCategories

通知类别优先。 PRIORITY_CATEGORY_ *常量的位掩码。

priorityMessageSenders

Added in API level 23
int priorityMessageSenders

通知发件人优先处理消息。 其中一个:PRIORITY_SENDERS_ANY,PRIORITY_SENDERS_CONTACTS,PRIORITY_SENDERS_STARRED

suppressedVisualEffects

Added in API level 24
int suppressedVisualEffects

视觉效果可以抑制通过“请勿打扰”模式过滤的通知。 SUPPRESSED_EFFECT_ *常量的位掩码。

Public constructors

NotificationManager.Policy

Added in API level 23
NotificationManager.Policy (int priorityCategories, 
                int priorityCallSenders, 
                int priorityMessageSenders)

构建“请勿打扰”优先模式行为的策略。

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.

NotificationManager.Policy

Added in API level 24
NotificationManager.Policy (int priorityCategories, 
                int priorityCallSenders, 
                int priorityMessageSenders, 
                int suppressedVisualEffects)

构建“请勿打扰”优先模式行为的策略。

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.

Public methods

describeContents

Added in API level 23
int describeContents ()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。 例如,如果对象将在writeToParcel(Parcel, int)的输出中包含writeToParcel(Parcel, int) ,则此方法的返回值必须包含CONTENTS_FILE_DESCRIPTOR位。

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

equals

Added in API level 23
boolean equals (Object o)

指示其他某个对象是否“等于”这一个。

equals方法在非空对象引用上实现等价关系:

  • 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.

equals方法Object实现对象上最可能的等价关系; 也就是说,对于任何非空参考值xy ,此方法返回true当且仅当xy引用同一对象( x == y具有值true )。

请注意,无论何时覆盖此方法,通常都必须覆盖 hashCode方法,以便维护 hashCode方法的一般合同,该方法声明等同对象必须具有相同的哈希代码。

Parameters
o Object: the reference object with which to compare.
Returns
boolean true if this object is the same as the obj argument; false otherwise.

hashCode

Added in API level 23
int hashCode ()

返回对象的哈希码值。 这种方法支持散列表的好处,例如HashMap提供的HashMap

一般合约 hashCode是:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

尽可能合理实用,类Object定义的hashCode方法确实为不同的对象返回不同的整数。 (这通常通过将对象的内部地址转换为整数来实现,但Java TM编程语言不需要此实现技术。)

Returns
int a hash code value for this object.

priorityCategoriesToString

Added in API level 23
String priorityCategoriesToString (int priorityCategories)

Parameters
priorityCategories int
Returns
String

prioritySendersToString

Added in API level 23
String prioritySendersToString (int prioritySenders)

Parameters
prioritySenders int
Returns
String

suppressedEffectsToString

Added in API level 24
String suppressedEffectsToString (int effects)

Parameters
effects int
Returns
String

toString

Added in API level 23
String toString ()

返回对象的字符串表示形式。 通常, toString方法将返回一个“文本表示”此对象的字符串。 结果应该是一个简洁但内容丰富的表述,对于一个人来说很容易阅读。 建议所有子类重写此方法。

ObjecttoString方法返回一个字符串,其中包含对象为实例的类的名称,符号字符“ @ ”以及对象的哈希代码的无符号十六进制表示形式。 换句话说,这个方法返回一个字符串,其值等于:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

Added in API level 23
void writeToParcel (Parcel dest, 
                int flags)

将此对象平铺到一个包裹中。

Parameters
dest Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

Hooray!