Android APIs
public class

StatusBarNotification

extends Object
implements Parcelable
java.lang.Object
   ↳ android.service.notification.StatusBarNotification

Class Overview

Class encapsulating a Notification. Sent by the NotificationManagerService to clients including the status bar and any NotificationListenerServices.

Summary

[Expand]
Inherited Constants
From interface 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()
Creates and returns a copy of this Object.
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
String getGroupKey()
A key that indicates the group with which this message ranks.
int getId()
The id supplied to notify(int, Notification).
String getKey()
A unique instance key for this notification record.
Notification getNotification()
String getPackageName()
The package of the app that posted the notification.
long getPostTime()
The time (in currentTimeMillis() time) the notification was posted, which may be different than when.
String getTag()
The tag supplied to notify(int, Notification), or null if no tag was specified.
UserHandle getUser()
The UserHandle for whom this notification is intended.
int getUserId()
This method was deprecated in API level 21. Use getUser() instead.
boolean isClearable()
Convenience method to check the notification's flags for either FLAG_ONGOING_EVENT or FLAG_NO_CLEAR.
boolean isOngoing()
Convenience method to check the notification's flags for FLAG_ONGOING_EVENT.
String toString()
Returns a string containing a concise, human-readable description of this object.
void writeToParcel(Parcel out, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<StatusBarNotification> CREATOR

Added in API level 18

Public Constructors

public StatusBarNotification (String pkg, String opPkg, int id, String tag, int uid, int initialPid, int score, Notification notification, UserHandle user, long postTime)

Added in API level 18

Parameters
pkg
opPkg
id
tag
uid
initialPid
score
notification
user
postTime

public StatusBarNotification (Parcel in)

Added in API level 18

Parameters
in

Public Methods

public StatusBarNotification clone ()

Added in API level 18

Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.

Returns
StatusBarNotification a copy of this object.

public int describeContents ()

Added in API level 18

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
int a bitmask indicating the set of special object types marshalled by the Parcelable.

public String getGroupKey ()

Added in API level 21

A key that indicates the group with which this message ranks.

Returns
String

public int getId ()

Added in API level 18

The id supplied to notify(int, Notification).

Returns
int

public String getKey ()

Added in API level 20

A unique instance key for this notification record.

Returns
String

public Notification getNotification ()

Added in API level 18

public String getPackageName ()

Added in API level 18

The package of the app that posted the notification.

Returns
String

public long getPostTime ()

Added in API level 18

The time (in currentTimeMillis() time) the notification was posted, which may be different than when.

Returns
long

public String getTag ()

Added in API level 18

The tag supplied to notify(int, Notification), or null if no tag was specified.

Returns
String

public UserHandle getUser ()

Added in API level 21

The UserHandle for whom this notification is intended.

Returns
UserHandle

public int getUserId ()

Added in API level 18

This method was deprecated in API level 21.
Use getUser() instead.

Returns a userHandle for the instance of the app that posted this notification.

Returns
int

public boolean isClearable ()

Added in API level 18

Convenience method to check the notification's flags for either FLAG_ONGOING_EVENT or FLAG_NO_CLEAR.

Returns
boolean

public boolean isOngoing ()

Added in API level 18

Convenience method to check the notification's flags for FLAG_ONGOING_EVENT.

Returns
boolean

public String toString ()

Added in API level 18

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

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

See Writing a useful toString method if you intend implementing your own toString method.

Returns
String a printable representation of this object.

public void writeToParcel (Parcel out, int flags)

Added in API level 18

Flatten this object in to a Parcel.

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