Methods Summary |
---|
public void | clear()Removes all elements from the mapping of this Bundle.
unparcel();
mMap.clear();
mHasFds = false;
mFdsKnown = true;
|
public java.lang.Object | clone()Clones the current Bundle. The internal map is cloned, but the keys and
values to which it refers are copied by reference.
return new Bundle(this);
|
public boolean | containsKey(java.lang.String key)Returns true if the given key is contained in the mapping
of this Bundle.
unparcel();
return mMap.containsKey(key);
|
public int | describeContents()Report the nature of this Parcelable's contents
int mask = 0;
if (hasFileDescriptors()) {
mask |= Parcelable.CONTENTS_FILE_DESCRIPTOR;
}
return mask;
|
public java.lang.Object | get(java.lang.String key)Returns the entry with the given key as an object.
unparcel();
return mMap.get(key);
|
public boolean | getBoolean(java.lang.String key)Returns the value associated with the given key, or false if
no mapping of the desired type exists for the given key.
unparcel();
return getBoolean(key, false);
|
public boolean | getBoolean(java.lang.String key, boolean defaultValue)Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Boolean) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Boolean", defaultValue, e);
return defaultValue;
}
|
public boolean[] | getBooleanArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (boolean[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "byte[]", e);
return null;
}
|
public android.os.Bundle | getBundle(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (Bundle) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Bundle", e);
return null;
}
|
public byte | getByte(java.lang.String key)Returns the value associated with the given key, or (byte) 0 if
no mapping of the desired type exists for the given key.
unparcel();
return getByte(key, (byte) 0);
|
public java.lang.Byte | getByte(java.lang.String key, byte defaultValue)Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Byte) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Byte", defaultValue, e);
return defaultValue;
}
|
public byte[] | getByteArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (byte[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "byte[]", e);
return null;
}
|
public char | getChar(java.lang.String key)Returns the value associated with the given key, or false if
no mapping of the desired type exists for the given key.
unparcel();
return getChar(key, (char) 0);
|
public char | getChar(java.lang.String key, char defaultValue)Returns the value associated with the given key, or (char) 0 if
no mapping of the desired type exists for the given key.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Character) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Character", defaultValue, e);
return defaultValue;
}
|
public char[] | getCharArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (char[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "char[]", e);
return null;
}
|
public java.lang.CharSequence | getCharSequence(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (CharSequence) o;
} catch (ClassCastException e) {
typeWarning(key, o, "CharSequence", e);
return null;
}
|
public double | getDouble(java.lang.String key)Returns the value associated with the given key, or 0.0 if
no mapping of the desired type exists for the given key.
unparcel();
return getDouble(key, 0.0);
|
public double | getDouble(java.lang.String key, double defaultValue)Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Double) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Double", defaultValue, e);
return defaultValue;
}
|
public double[] | getDoubleArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (double[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "double[]", e);
return null;
}
|
public float | getFloat(java.lang.String key)Returns the value associated with the given key, or 0.0f if
no mapping of the desired type exists for the given key.
unparcel();
return getFloat(key, 0.0f);
|
public float | getFloat(java.lang.String key, float defaultValue)Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Float) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Float", defaultValue, e);
return defaultValue;
}
|
public float[] | getFloatArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (float[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "float[]", e);
return null;
}
|
public IBinder | getIBinder(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (IBinder) o;
} catch (ClassCastException e) {
typeWarning(key, o, "IBinder", e);
return null;
}
|
public int | getInt(java.lang.String key)Returns the value associated with the given key, or 0 if
no mapping of the desired type exists for the given key.
unparcel();
return getInt(key, 0);
|
public int | getInt(java.lang.String key, int defaultValue)Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Integer) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Integer", defaultValue, e);
return defaultValue;
}
|
public int[] | getIntArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (int[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "int[]", e);
return null;
}
|
public java.util.ArrayList | getIntegerArrayList(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (ArrayList<Integer>) o;
} catch (ClassCastException e) {
typeWarning(key, o, "ArrayList<Integer>", e);
return null;
}
|
public long | getLong(java.lang.String key)Returns the value associated with the given key, or 0L if
no mapping of the desired type exists for the given key.
unparcel();
return getLong(key, 0L);
|
public long | getLong(java.lang.String key, long defaultValue)Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Long) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Long", defaultValue, e);
return defaultValue;
}
|
public long[] | getLongArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (long[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "long[]", e);
return null;
}
|
public T | getParcelable(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (T) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Parcelable", e);
return null;
}
|
public Parcelable[] | getParcelableArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (Parcelable[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Parcelable[]", e);
return null;
}
|
public java.util.ArrayList | getParcelableArrayList(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (ArrayList<T>) o;
} catch (ClassCastException e) {
typeWarning(key, o, "ArrayList", e);
return null;
}
|
public java.io.Serializable | getSerializable(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (Serializable) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Serializable", e);
return null;
}
|
public short | getShort(java.lang.String key)Returns the value associated with the given key, or (short) 0 if
no mapping of the desired type exists for the given key.
unparcel();
return getShort(key, (short) 0);
|
public short | getShort(java.lang.String key, short defaultValue)Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Short) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Short", defaultValue, e);
return defaultValue;
}
|
public short[] | getShortArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (short[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "short[]", e);
return null;
}
|
public android.util.SparseArray | getSparseParcelableArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (SparseArray<T>) o;
} catch (ClassCastException e) {
typeWarning(key, o, "SparseArray", e);
return null;
}
|
public java.lang.String | getString(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (String) o;
} catch (ClassCastException e) {
typeWarning(key, o, "String", e);
return null;
}
|
public java.lang.String[] | getStringArray(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (String[]) o;
} catch (ClassCastException e) {
typeWarning(key, o, "String[]", e);
return null;
}
|
public java.util.ArrayList | getStringArrayList(java.lang.String key)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.
unparcel();
Object o = mMap.get(key);
if (o == null) {
return null;
}
try {
return (ArrayList<String>) o;
} catch (ClassCastException e) {
typeWarning(key, o, "ArrayList<String>", e);
return null;
}
|
public boolean | hasFileDescriptors()Reports whether the bundle contains any parcelled file descriptors.
if (!mFdsKnown) {
boolean fdFound = false; // keep going until we find one or run out of data
if (mParcelledData != null) {
if (mParcelledData.hasFileDescriptors()) {
fdFound = true;
}
} else {
// It's been unparcelled, so we need to walk the map
Iterator<Map.Entry<String, Object>> iter = mMap.entrySet().iterator();
while (!fdFound && iter.hasNext()) {
Object obj = iter.next().getValue();
if (obj instanceof Parcelable) {
if ((((Parcelable)obj).describeContents()
& Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
fdFound = true;
break;
}
} else if (obj instanceof Parcelable[]) {
Parcelable[] array = (Parcelable[]) obj;
for (int n = array.length - 1; n >= 0; n--) {
if ((array[n].describeContents()
& Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
fdFound = true;
break;
}
}
} else if (obj instanceof SparseArray) {
SparseArray<? extends Parcelable> array =
(SparseArray<? extends Parcelable>) obj;
for (int n = array.size() - 1; n >= 0; n--) {
if ((array.get(n).describeContents()
& Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
fdFound = true;
break;
}
}
} else if (obj instanceof ArrayList) {
ArrayList array = (ArrayList) obj;
// an ArrayList here might contain either Strings or
// Parcelables; only look inside for Parcelables
if ((array.size() > 0)
&& (array.get(0) instanceof Parcelable)) {
for (int n = array.size() - 1; n >= 0; n--) {
Parcelable p = (Parcelable) array.get(n);
if (p != null && ((p.describeContents()
& Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0)) {
fdFound = true;
break;
}
}
}
}
}
}
mHasFds = fdFound;
mFdsKnown = true;
}
return mHasFds;
|
public boolean | isEmpty()Returns true if the mapping of this Bundle is empty, false otherwise.
unparcel();
return mMap.isEmpty();
|
public java.util.Set | keySet()Returns a Set containing the Strings used as keys in this Bundle.
unparcel();
return mMap.keySet();
|
public void | putAll(android.os.Bundle map)Inserts all mappings from the given Bundle into this Bundle.
unparcel();
map.unparcel();
mMap.putAll(map.mMap);
// fd state is now known if and only if both bundles already knew
mHasFds |= map.mHasFds;
mFdsKnown = mFdsKnown && map.mFdsKnown;
|
public void | putBoolean(java.lang.String key, boolean value)Inserts a Boolean value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putBooleanArray(java.lang.String key, boolean[] value)Inserts a boolean array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putBundle(java.lang.String key, android.os.Bundle value)Inserts a Bundle value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putByte(java.lang.String key, byte value)Inserts a byte value into the mapping of this Bundle, replacing
any existing value for the given key.
unparcel();
mMap.put(key, value);
|
public void | putByteArray(java.lang.String key, byte[] value)Inserts a byte array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putChar(java.lang.String key, char value)Inserts a char value into the mapping of this Bundle, replacing
any existing value for the given key.
unparcel();
mMap.put(key, value);
|
public void | putCharArray(java.lang.String key, char[] value)Inserts a char array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putCharSequence(java.lang.String key, java.lang.CharSequence value)Inserts a CharSequence value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putDouble(java.lang.String key, double value)Inserts a double value into the mapping of this Bundle, replacing
any existing value for the given key.
unparcel();
mMap.put(key, value);
|
public void | putDoubleArray(java.lang.String key, double[] value)Inserts a double array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putFloat(java.lang.String key, float value)Inserts a float value into the mapping of this Bundle, replacing
any existing value for the given key.
unparcel();
mMap.put(key, value);
|
public void | putFloatArray(java.lang.String key, float[] value)Inserts a float array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putIBinder(java.lang.String key, IBinder value)Inserts an IBinder value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putInt(java.lang.String key, int value)Inserts an int value into the mapping of this Bundle, replacing
any existing value for the given key.
unparcel();
mMap.put(key, value);
|
public void | putIntArray(java.lang.String key, int[] value)Inserts an int array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putIntegerArrayList(java.lang.String key, java.util.ArrayList value)Inserts an ArrayList value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putLong(java.lang.String key, long value)Inserts a long value into the mapping of this Bundle, replacing
any existing value for the given key.
unparcel();
mMap.put(key, value);
|
public void | putLongArray(java.lang.String key, long[] value)Inserts a long array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putParcelable(java.lang.String key, Parcelable value)Inserts a Parcelable value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
mFdsKnown = false;
|
public void | putParcelableArray(java.lang.String key, Parcelable[] value)Inserts an array of Parcelable values into the mapping of this Bundle,
replacing any existing value for the given key. Either key or value may
be null.
unparcel();
mMap.put(key, value);
mFdsKnown = false;
|
public void | putParcelableArrayList(java.lang.String key, java.util.ArrayList value)Inserts a List of Parcelable values into the mapping of this Bundle,
replacing any existing value for the given key. Either key or value may
be null.
unparcel();
mMap.put(key, value);
mFdsKnown = false;
|
public void | putSerializable(java.lang.String key, java.io.Serializable value)Inserts a Serializable value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putShort(java.lang.String key, short value)Inserts a short value into the mapping of this Bundle, replacing
any existing value for the given key.
unparcel();
mMap.put(key, value);
|
public void | putShortArray(java.lang.String key, short[] value)Inserts a short array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putSparseParcelableArray(java.lang.String key, android.util.SparseArray value)Inserts a SparceArray of Parcelable values into the mapping of this
Bundle, replacing any existing value for the given key. Either key
or value may be null.
unparcel();
mMap.put(key, value);
mFdsKnown = false;
|
public void | putString(java.lang.String key, java.lang.String value)Inserts a String value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putStringArray(java.lang.String key, java.lang.String[] value)Inserts a String array value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | putStringArrayList(java.lang.String key, java.util.ArrayList value)Inserts an ArrayList value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
unparcel();
mMap.put(key, value);
|
public void | readFromParcel(Parcel parcel)Reads the Parcel contents into this Bundle, typically in order for
it to be passed through an IBinder connection.
mParcelledData = parcel;
mHasFds = mParcelledData.hasFileDescriptors();
mFdsKnown = true;
|
public void | remove(java.lang.String key)Removes any entry with the given key from the mapping of this Bundle.
unparcel();
mMap.remove(key);
|
public void | setClassLoader(java.lang.ClassLoader loader)Changes the ClassLoader this Bundle uses when instantiating objects.
mClassLoader = loader;
|
public int | size()Returns the number of mappings contained in this Bundle.
unparcel();
return mMap.size();
|
public synchronized java.lang.String | toString()
if (mParcelledData != null) {
return "Bundle[mParcelledData.dataSize=" +
mParcelledData.dataSize() + "]";
}
return "Bundle[" + mMap.toString() + "]";
|
private void | typeWarning(java.lang.String key, java.lang.Object value, java.lang.String className, java.lang.Object defaultValue, java.lang.ClassCastException e)
StringBuilder sb = new StringBuilder();
sb.append("Key ");
sb.append(key);
sb.append(" expected ");
sb.append(className);
sb.append(" but value was a ");
sb.append(value.getClass().getName());
sb.append(". The default value ");
sb.append(defaultValue);
sb.append(" was returned.");
Log.w(LOG_TAG, sb.toString());
Log.w(LOG_TAG, "Attempt to cast generated internal exception:", e);
|
private void | typeWarning(java.lang.String key, java.lang.Object value, java.lang.String className, java.lang.ClassCastException e)
typeWarning(key, value, className, "<null>", e);
|
synchronized void | unparcel()If the underlying data are stored as a Parcel, unparcel them
using the currently assigned class loader.
if (mParcelledData == null) {
return;
}
mParcelledData.setDataPosition(0);
Bundle b = mParcelledData.readBundleUnpacked(mClassLoader);
mMap = b.mMap;
mHasFds = mParcelledData.hasFileDescriptors();
mFdsKnown = true;
mParcelledData.recycle();
mParcelledData = null;
|
public void | writeToParcel(Parcel parcel, int flags)Writes the Bundle contents to a Parcel, typically in order for
it to be passed through an IBinder connection.
parcel.writeBundle(this);
|