diff options
| author | Fred Quintana <fredq@google.com> | 2009-09-25 14:23:13 -0700 |
|---|---|---|
| committer | Fred Quintana <fredq@google.com> | 2009-09-25 16:01:22 -0700 |
| commit | 6ecaff15836581336b1e8fad6ac42f3ff4a13544 (patch) | |
| tree | 426b0080e3d1ae9007f037dffebf10a7ed30d8bf /core/java/android/app/NotificationManager.java | |
| parent | ed7f0955b7a4535c963b0de2b89e41febfd1416e (diff) | |
add a optional String to the key of notifications to allow users
to scope them
Diffstat (limited to 'core/java/android/app/NotificationManager.java')
| -rw-r--r-- | core/java/android/app/NotificationManager.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 7b51fdf9b5cb..6fe12fcf0bda 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -87,12 +87,27 @@ public class NotificationManager */ public void notify(int id, Notification notification) { + notify(null, id, notification); + } + + /** + * Persistent notification on the status bar, + * + * @param tag An string identifier for this notification unique within your + * application. + * @param notification A {@link Notification} object describing how to + * notify the user, other than the view you're providing. Must not be null. + * @return the id of the notification that is associated with the string identifier that + * can be used to cancel the notification + */ + public void notify(String tag, int id, Notification notification) + { int[] idOut = new int[1]; INotificationManager service = getService(); String pkg = mContext.getPackageName(); if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")"); try { - service.enqueueNotification(pkg, id, notification, idOut); + service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut); if (id != idOut[0]) { Log.w(TAG, "notify: id corrupted: sent " + id + ", got back " + idOut[0]); } @@ -107,11 +122,21 @@ public class NotificationManager */ public void cancel(int id) { + cancel(null, id); + } + + /** + * Cancel a previously shown notification. If it's transient, the view + * will be hidden. If it's persistent, it will be removed from the status + * bar. + */ + public void cancel(String tag, int id) + { INotificationManager service = getService(); String pkg = mContext.getPackageName(); if (localLOGV) Log.v(TAG, pkg + ": cancel(" + id + ")"); try { - service.cancelNotification(pkg, id); + service.cancelNotificationWithTag(pkg, tag, id); } catch (RemoteException e) { } } |
