StatusBarNotificationpublic class StatusBarNotification extends Object implements android.os.ParcelableClass encapsulating a Notification. Sent by the NotificationManagerService to clients including
the status bar and any {@link android.service.notification.NotificationListenerService}s. |
Fields Summary |
---|
private final String | pkg | private final int | id | private final String | tag | private final String | key | private final String | groupKey | private final int | uid | private final String | opPkg | private final int | initialPid | private final android.app.Notification | notification | private final android.os.UserHandle | user | private final long | postTime | private final int | score | public static final Parcelable.Creator | CREATOR |
Constructors Summary |
---|
public StatusBarNotification(String pkg, String opPkg, int id, String tag, int uid, int initialPid, int score, android.app.Notification notification, android.os.UserHandle user)
this(pkg, opPkg, id, tag, uid, initialPid, score, notification, user,
System.currentTimeMillis());
| public StatusBarNotification(String pkg, String opPkg, int id, String tag, int uid, int initialPid, int score, android.app.Notification notification, android.os.UserHandle user, long postTime)
if (pkg == null) throw new NullPointerException();
if (notification == null) throw new NullPointerException();
this.pkg = pkg;
this.opPkg = opPkg;
this.id = id;
this.tag = tag;
this.uid = uid;
this.initialPid = initialPid;
this.score = score;
this.notification = notification;
this.user = user;
this.postTime = postTime;
this.key = key();
this.groupKey = groupKey();
| public StatusBarNotification(android.os.Parcel in)
this.pkg = in.readString();
this.opPkg = in.readString();
this.id = in.readInt();
if (in.readInt() != 0) {
this.tag = in.readString();
} else {
this.tag = null;
}
this.uid = in.readInt();
this.initialPid = in.readInt();
this.score = in.readInt();
this.notification = new Notification(in);
this.user = UserHandle.readFromParcel(in);
this.postTime = in.readLong();
this.key = key();
this.groupKey = groupKey();
|
Methods Summary |
---|
public android.service.notification.StatusBarNotification | clone()
return new StatusBarNotification(this.pkg, this.opPkg,
this.id, this.tag, this.uid, this.initialPid,
this.score, this.notification.clone(), this.user, this.postTime);
| public android.service.notification.StatusBarNotification | cloneLight()
final Notification no = new Notification();
this.notification.cloneInto(no, false); // light copy
return new StatusBarNotification(this.pkg, this.opPkg,
this.id, this.tag, this.uid, this.initialPid,
this.score, no, this.user, this.postTime);
| public int | describeContents()
return 0;
| public java.lang.String | getGroupKey()A key that indicates the group with which this message ranks.
return groupKey;
| public int | getId()The id supplied to {@link android.app.NotificationManager#notify(int,Notification)}.
return id;
| public int | getInitialPid()
return initialPid;
| public java.lang.String | getKey()A unique instance key for this notification record.
return key;
| public android.app.Notification | getNotification()The {@link android.app.Notification} supplied to
{@link android.app.NotificationManager#notify(int,Notification)}.
return notification;
| public java.lang.String | getOpPkg()The package used for AppOps tracking. @hide
return opPkg;
| public java.lang.String | getPackageName()The package of the app that posted the notification.
return pkg;
| public long | getPostTime()The time (in {@link System#currentTimeMillis} time) the notification was posted,
which may be different than {@link android.app.Notification#when}.
return postTime;
| public int | getScore()
return score;
| public java.lang.String | getTag()The tag supplied to {@link android.app.NotificationManager#notify(int,Notification)},
or null if no tag was specified.
return tag;
| public int | getUid()The notifying app's calling uid. @hide
return uid;
| public android.os.UserHandle | getUser()The {@link android.os.UserHandle} for whom this notification is intended.
return user;
| public int | getUserId()Returns a userHandle for the instance of the app that posted this notification.
return this.user.getIdentifier();
| private java.lang.String | groupKey()
final String group = getNotification().getGroup();
final String sortKey = getNotification().getSortKey();
if (group == null && sortKey == null) {
// a group of one
return key;
}
return user.getIdentifier() + "|" + pkg + "|" +
(group == null
? "p:" + notification.priority
: "g:" + group);
| public boolean | isClearable()Convenience method to check the notification's flags for
either {@link Notification#FLAG_ONGOING_EVENT} or
{@link Notification#FLAG_NO_CLEAR}.
return ((notification.flags & Notification.FLAG_ONGOING_EVENT) == 0)
&& ((notification.flags & Notification.FLAG_NO_CLEAR) == 0);
| public boolean | isOngoing()Convenience method to check the notification's flags for
{@link Notification#FLAG_ONGOING_EVENT}.
return (notification.flags & Notification.FLAG_ONGOING_EVENT) != 0;
| private java.lang.String | key()
return user.getIdentifier() + "|" + pkg + "|" + id + "|" + tag + "|" + uid;
| public java.lang.String | toString()
return String.format(
"StatusBarNotification(pkg=%s user=%s id=%d tag=%s score=%d key=%s: %s)",
this.pkg, this.user, this.id, this.tag,
this.score, this.key, this.notification);
| public void | writeToParcel(android.os.Parcel out, int flags)
out.writeString(this.pkg);
out.writeString(this.opPkg);
out.writeInt(this.id);
if (this.tag != null) {
out.writeInt(1);
out.writeString(this.tag);
} else {
out.writeInt(0);
}
out.writeInt(this.uid);
out.writeInt(this.initialPid);
out.writeInt(this.score);
this.notification.writeToParcel(out, flags);
user.writeToParcel(out, flags);
out.writeLong(this.postTime);
|
|