public class StatusBarNotification
extends Object implements Parcelable
| java.lang.Object | |
| android.service.notification.StatusBarNotification | |
封装通知的类。 由NotificationManagerService发送给客户端,包括状态栏和任何NotificationListenerService 。
Inherited constants |
|---|
android.os.Parcelable
|
Fields |
|
|---|---|
public static final Creator<StatusBarNotification> |
CREATOR |
Public constructors |
|
|---|---|
StatusBarNotification(String pkg, String opPkg, int id, String tag, int uid, int initialPid, int score, Notification notification, UserHandle user, long postTime) |
|
StatusBarNotification(Parcel in) |
|
公共方法(Public methods) |
|
|---|---|
StatusBarNotification |
clone() 创建并返回此对象的副本。 |
int |
describeContents() 描述此Parcelable实例的封送表示中包含的特殊对象的种类。 |
String |
getGroupKey() 指示此消息排列的组的密钥。 |
int |
getId() 该ID提供给 |
String |
getKey() 此通知记录的唯一实例密钥。 |
Notification |
getNotification() |
String |
getOverrideGroupKey() 返回覆盖组键。 |
String |
getPackageName() 发布通知的应用程序包。 |
long |
getPostTime() 发布通知的时间(在 |
String |
getTag() 提供给 |
UserHandle |
getUser()
|
int |
getUserId() 此方法在API级别21中已弃用。请改用 |
boolean |
isClearable() 便捷方法检查 |
boolean |
isGroup() 如果此通知是组的一部分,则返回true。 |
boolean |
isOngoing() 检查 |
void |
setOverrideGroupKey(String overrideGroupKey) 设置覆盖组键。 |
String |
toString() 返回对象的字符串表示形式。 |
void |
writeToParcel(Parcel out, int flags) 将此对象平铺到一个包裹中。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
android.os.Parcelable
|
|
StatusBarNotification (String pkg, String opPkg, int id, String tag, int uid, int initialPid, int score, Notification notification, UserHandle user, long postTime)
| 参数(Parameters) | |
|---|---|
pkg |
String
|
opPkg |
String
|
id |
int
|
tag |
String
|
uid |
int
|
initialPid |
int
|
score |
int
|
notification |
Notification
|
user |
UserHandle
|
postTime |
long
|
StatusBarNotification (Parcel in)
| 参数(Parameters) | |
|---|---|
in |
Parcel
|
StatusBarNotification clone ()
创建并返回此对象的副本。 “复制”的确切含义可能取决于对象的类别。 一般意图是,对于任何对象x ,表达式:
will be true, and that the expression:x.clone() != x
will bex.clone().getClass() == x.getClass()
true, but these are not absolute requirements. While it is typically the case that:
will bex.clone().equals(x)
true, this is not an absolute requirement.
按照惯例,返回的对象应该通过调用super.clone获得。 如果一个类和它的所有超类( Object除外)都遵守这个约定,那就是x.clone().getClass() == x.getClass() 。
按照惯例,这个方法返回的对象应该独立于这个对象(被克隆)。 要实现这种独立性,可能需要在返回super.clone之前修改返回的对象的一个或多个字段。 通常,这意味着复制包含被克隆对象的内部“深层结构”的任何可变对象,并将这些对象的引用替换为对这些副本的引用。 如果一个类只包含原始字段或对不可变对象的引用,那么通常情况下不需要修改super.clone返回的对象中的字段。
类Object的方法clone执行特定的克隆操作。 首先,如果该对象的类没有实现接口Cloneable ,则引发CloneNotSupportedException 。 请注意,所有数组都被视为实现接口Cloneable并且数组类型T[]的clone方法的返回类型为T[] ,其中T是任何引用或基本类型。 否则,此方法创建该对象的类的新实例,并使用该对象的相应字段的内容来初始化其所有字段,就像通过赋值一样; 这些字段的内容本身并不克隆。 因此,此方法执行此对象的“浅拷贝”,而不是“深拷贝”操作。
类 Object本身并不实现接口 Cloneable ,所以在类为 Object的对象上调用 clone方法将导致在运行时抛出异常。
| 返回(Returns) | |
|---|---|
StatusBarNotification |
a clone of this instance. |
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. |
Notification getNotification ()
Notification提供给 notify(int, Notification) 。
| 返回(Returns) | |
|---|---|
Notification |
|
long getPostTime ()
发布通知的时间(在 currentTimeMillis()时间),可能与 when不同。
| 返回(Returns) | |
|---|---|
long |
|
String getTag ()
该标记提供给 notify(int, Notification) ,如果未指定标记, notify(int, Notification) null。
| 返回(Returns) | |
|---|---|
String |
|
int getUserId ()
此方法在API级别21中已弃用。
改为使用getUser() 。
为发布此通知的应用程序的实例返回一个userHandle。
| 返回(Returns) | |
|---|---|
int |
|
boolean isClearable ()
便捷方法检查 FLAG_ONGOING_EVENT或 FLAG_NO_CLEAR的通知标志。
| 返回(Returns) | |
|---|---|
boolean |
|
boolean isOngoing ()
便捷方法检查通知的标志为 FLAG_ONGOING_EVENT 。
| 返回(Returns) | |
|---|---|
boolean |
|
void setOverrideGroupKey (String overrideGroupKey)
设置覆盖组键。
| 参数(Parameters) | |
|---|---|
overrideGroupKey |
String
|
String toString ()
返回对象的字符串表示形式。 一般来说, toString方法返回一个“文本表示”该对象的字符串。 结果应该是一个简洁但内容丰富的表述,对于一个人来说很容易阅读。 建议所有子类重写此方法。
类Object的toString方法返回一个字符串,其中包含对象为实例的类的名称,符号字符“ @ ”以及对象的哈希代码的无符号十六进制表示形式。 换句话说,这个方法返回一个字符串,其值等于:
getClass().getName() + '@' + Integer.toHexString(hashCode())
| 返回(Returns) | |
|---|---|
String |
a string representation of the object. |
void writeToParcel (Parcel out, int flags)
将此对象平铺到一个包裹中。
| 参数(Parameters) | |
|---|---|
out |
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. |