FileDocCategorySizeDatePackage
StatusBarNotification.javaAPI DocAndroid 5.1 API8168Thu Mar 12 22:22:10 GMT 2015android.service.notification

StatusBarNotification

public class StatusBarNotification extends Object implements android.os.Parcelable
Class 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)

hide

        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.StatusBarNotificationclone()

        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.StatusBarNotificationcloneLight()

hide


          
       
        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 intdescribeContents()

        return 0;
    
public java.lang.StringgetGroupKey()
A key that indicates the group with which this message ranks.

        return groupKey;
    
public intgetId()
The id supplied to {@link android.app.NotificationManager#notify(int,Notification)}.

        return id;
    
public intgetInitialPid()

hide

        return initialPid;
    
public java.lang.StringgetKey()
A unique instance key for this notification record.

        return key;
    
public android.app.NotificationgetNotification()
The {@link android.app.Notification} supplied to {@link android.app.NotificationManager#notify(int,Notification)}.

        return notification;
    
public java.lang.StringgetOpPkg()
The package used for AppOps tracking. @hide

        return opPkg;
    
public java.lang.StringgetPackageName()
The package of the app that posted the notification.

        return pkg;
    
public longgetPostTime()
The time (in {@link System#currentTimeMillis} time) the notification was posted, which may be different than {@link android.app.Notification#when}.

        return postTime;
    
public intgetScore()

hide

        return score;
    
public java.lang.StringgetTag()
The tag supplied to {@link android.app.NotificationManager#notify(int,Notification)}, or null if no tag was specified.

        return tag;
    
public intgetUid()
The notifying app's calling uid. @hide

        return uid;
    
public android.os.UserHandlegetUser()
The {@link android.os.UserHandle} for whom this notification is intended.

        return user;
    
public intgetUserId()
Returns a userHandle for the instance of the app that posted this notification.

deprecated
Use {@link #getUser()} instead.

        return this.user.getIdentifier();
    
private java.lang.StringgroupKey()

        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 booleanisClearable()
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 booleanisOngoing()
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.Stringkey()

        return user.getIdentifier() + "|" + pkg + "|" + id + "|" + tag + "|" + uid;
    
public java.lang.StringtoString()

        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 voidwriteToParcel(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);