diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-03-03 22:23:07 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-03 22:23:07 -0800 |
commit | 48f91e35c5188f3dc78c12b8e8638a248221691b (patch) | |
tree | b4921f287b2d23044f7bd9b865d0cce06474497f /core/java/android/os/Bundle.java | |
parent | 1e158e9ce78c25dc5de402f14654a8955de7fddc (diff) | |
parent | e3a7f628c6d9fef42be24999b3137ebe5c6f3525 (diff) | |
download | frameworks_base-48f91e35c5188f3dc78c12b8e8638a248221691b.zip frameworks_base-48f91e35c5188f3dc78c12b8e8638a248221691b.tar.gz frameworks_base-48f91e35c5188f3dc78c12b8e8638a248221691b.tar.bz2 |
Merge "Fix Fragment.onInflate() to actually work correctly." into honeycomb-mr1
Diffstat (limited to 'core/java/android/os/Bundle.java')
-rw-r--r-- | core/java/android/os/Bundle.java | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java index 8eac7aa..c288f8a 100644 --- a/core/java/android/os/Bundle.java +++ b/core/java/android/os/Bundle.java @@ -1028,7 +1028,6 @@ public final class Bundle implements Parcelable, Cloneable { } } - /** * Returns the value associated with the given key, or null if * no mapping of the desired type exists for the given key or a null @@ -1052,6 +1051,28 @@ public final class Bundle implements Parcelable, Cloneable { } /** + * Returns the value associated with the given key, or defaultValue if + * no mapping of the desired type exists for the given key. + * + * @param key a String, or null + * @param defaultValue Value to return if key does not exist + * @return a String value, or null + */ + public String getString(String key, String defaultValue) { + unparcel(); + Object o = mMap.get(key); + if (o == null) { + return defaultValue; + } + try { + return (String) o; + } catch (ClassCastException e) { + typeWarning(key, o, "String", e); + return defaultValue; + } + } + + /** * Returns the value associated with the given key, or null if * no mapping of the desired type exists for the given key or a null * value is explicitly associated with the key. @@ -1074,6 +1095,28 @@ public final class Bundle implements Parcelable, Cloneable { } /** + * Returns the value associated with the given key, or defaultValue if + * no mapping of the desired type exists for the given key. + * + * @param key a String, or null + * @param defaultValue Value to return if key does not exist + * @return a CharSequence value, or null + */ + public CharSequence getCharSequence(String key, CharSequence defaultValue) { + unparcel(); + Object o = mMap.get(key); + if (o == null) { + return defaultValue; + } + try { + return (CharSequence) o; + } catch (ClassCastException e) { + typeWarning(key, o, "CharSequence", e); + return defaultValue; + } + } + + /** * Returns the value associated with the given key, or null if * no mapping of the desired type exists for the given key or a null * value is explicitly associated with the key. |