public class Notification extends Object
Notify.init()
.Modifier and Type | Class and Description |
---|---|
static interface |
Notification.Action
Callback invoked when an added action is invoked.
|
static interface |
Notification.Closed
Signal emmitted when a notification is closed.
|
Modifier and Type | Field and Description |
---|---|
static int |
NOTIFY_EXPIRES_DEFAULT
Constant for default timeout duration.
|
static int |
NOTIFY_EXPIRES_NEVER
Constant for infinite timeout duration.
|
Constructor and Description |
---|
Notification(String summary,
String body,
String icon)
Create a new notification.
|
Modifier and Type | Method and Description |
---|---|
void |
addAction(String actionID,
String label,
Notification.Action action)
Add an action to a notification.
|
void |
clearActions()
Remove all added actions.
|
void |
clearHints()
Clear hints from the notification.
|
void |
close()
Hide the notification on screen.
|
void |
connect(Notification.Closed handler)
Hook up a handler to receive
Notification.Closed events on
this Notification. |
void |
setCategory(String category)
Set the category of the notification which may later be used to display
or filter out the notification.
|
void |
setHint(String key,
byte value)
Sets a hint with a byte value.
|
void |
setHint(String key,
byte[] value)
Sets a hint with a byte array data.
|
void |
setHint(String key,
double value)
Sets a hint with a double value.
|
void |
setHint(String key,
int value)
Sets a hint with an integer value.
|
void |
setHint(String key,
String value)
Sets a hint with a string value.
|
void |
setIcon(Pixbuf icon)
Sets the icon of the notification from a
Pixbuf . |
void |
setTimeout(int timeout)
Set the timeout that the notification disappears in milliseconds.
|
void |
setUrgency(Urgency urgency)
|
void |
show()
Display the notification on screen.
|
void |
update(String summary,
String body,
String icon)
Updates the notification with given parameters see
Notification() for
parameters. |
public static final int NOTIFY_EXPIRES_DEFAULT
public static final int NOTIFY_EXPIRES_NEVER
public Notification(String summary, String body, String icon)
The summary appears on the titlebar of notification and body appears as its text. Icon may be a string defining a theme icon or the filename identifying the icon that appears next to text.
Note that all but summary can be null
.
public void addAction(String actionID, String label, Notification.Action action)
Note that for some bizarre reason the new Notify-OSD of Ubuntu Linux
does not support actions at all. To determine if notification system
supports actions look for "actions"
in
capabilities.
Notify.getServerCapabilities()
public void clearActions()
public void clearHints()
public void close()
public void connect(Notification.Closed handler)
Notification.Closed
events on
this Notification.public void setCategory(String category)
public void setHint(String key, byte value)
Hints are interpreted by the notification system in various ways to modify the notification behavior and/or appearance. See the "Hints" section in Desktop Notifications Specification for standard hints and their interpretations.
public void setHint(String key, byte[] value)
setHint()
for further details.public void setHint(String key, double value)
setHint()
for further details.public void setHint(String key, int value)
setHint()
for further details.
Example: "x"
(sets the horizontal position of the
notification)
public void setHint(String key, String value)
setHint()
for further details.
Example: "sound-file"
(adds sound to the notification)
public void setIcon(Pixbuf icon)
Pixbuf
.public void setTimeout(int timeout)
NOTIFY_EXPIRES_DEFAULT
for
the default timeout duration. Use
NOTIFY_EXPIRES_NEVER
for
infinite timeout duration.public void setUrgency(Urgency urgency)
public void show()
public void update(String summary, String body, String icon)
Notification()
for
parameters.