diff options
author | Griff Hazen <griff@google.com> | 2014-03-06 02:57:21 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-03-06 02:57:21 +0000 |
commit | 5ab311550f01412c12c1c68fe75ae929c9d1e9d8 (patch) | |
tree | 6a67e067e76acc5a4c6bec11ac653724396882b5 /core | |
parent | a6434b5e8099060066b94921660437d29aeca78e (diff) | |
parent | 6daf22ca7680261e07dfd298a43d6e473e6c06f6 (diff) | |
download | frameworks_base-5ab311550f01412c12c1c68fe75ae929c9d1e9d8.zip frameworks_base-5ab311550f01412c12c1c68fe75ae929c9d1e9d8.tar.gz frameworks_base-5ab311550f01412c12c1c68fe75ae929c9d1e9d8.tar.bz2 |
am 6daf22ca: am 47826bfa: am c748341a: Merge "Add addExtras and getExtras to Notification.Builder." into klp-modular-dev
* commit '6daf22ca7680261e07dfd298a43d6e473e6c06f6':
Add addExtras and getExtras to Notification.Builder.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/Notification.java | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index b067cd0..cd1fbf6 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -1680,12 +1680,31 @@ public class Notification implements Parcelable } /** - * Add metadata to this notification. + * Merge additional metadata into this notification. * - * A reference to the Bundle is held for the lifetime of this Builder, and the Bundle's + * <p>Values within the Bundle will replace existing extras values in this Builder. + * + * @see Notification#extras + */ + public Builder addExtras(Bundle bag) { + if (mExtras == null) { + mExtras = new Bundle(bag); + } else { + mExtras.putAll(bag); + } + return this; + } + + /** + * Set metadata for this notification. + * + * <p>A reference to the Bundle is held for the lifetime of this Builder, and the Bundle's * current contents are copied into the Notification each time {@link #build()} is * called. * + * <p>Replaces any existing extras values with those from the provided Bundle. + * Use {@link #addExtras} to merge in metadata instead. + * * @see Notification#extras */ public Builder setExtras(Bundle bag) { @@ -1694,6 +1713,23 @@ public class Notification implements Parcelable } /** + * Get the current metadata Bundle used by this notification Builder. + * + * <p>The returned Bundle is shared with this Builder. + * + * <p>The current contents of this Bundle are copied into the Notification each time + * {@link #build()} is called. + * + * @see Notification#extras + */ + public Bundle getExtras() { + if (mExtras == null) { + mExtras = new Bundle(); + } + return mExtras; + } + + /** * Add an action to this notification. Actions are typically displayed by * the system as a button adjacent to the notification content. * <p> @@ -1989,7 +2025,7 @@ public class Notification implements Parcelable * this Notification object. * @hide */ - public void addExtras(Bundle extras) { + public void populateExtras(Bundle extras) { // Store original information used in the construction of this object extras.putCharSequence(EXTRA_TITLE, mContentTitle); extras.putCharSequence(EXTRA_TEXT, mContentText); @@ -2027,7 +2063,7 @@ public class Notification implements Parcelable n.extras = mExtras != null ? new Bundle(mExtras) : new Bundle(); - addExtras(n.extras); + populateExtras(n.extras); if (mStyle != null) { mStyle.addExtras(n.extras); } |