public final class Bundle extends BaseBundle implements Cloneable, Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>| Modifier and Type | Field and Description |
|---|---|
static Parcelable.Creator<Bundle> |
CREATOR
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.
|
static Bundle |
EMPTY |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE| Constructor and Description |
|---|
Bundle()
Constructs a new, empty Bundle.
|
Bundle(Bundle b)
Constructs a Bundle containing a copy of the mappings from the given
Bundle.
|
Bundle(ClassLoader loader)
Constructs a new, empty Bundle that uses a specific ClassLoader for
instantiating Parcelable and Serializable objects.
|
Bundle(int capacity)
Constructs a new, empty Bundle sized to hold the given number of
elements.
|
Bundle(PersistableBundle b)
Constructs a Bundle containing a copy of the mappings from the given
PersistableBundle.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all elements from the mapping of this Bundle.
|
Object |
clone()
Clones the current Bundle.
|
int |
describeContents()
Report the nature of this Parcelable's contents
|
void |
filterValues()
Filter values in Bundle to only basic types.
|
static Bundle |
forPair(String key,
String value)
Make a Bundle for a single key/value pair.
|
boolean[] |
getBooleanArray(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.
|
Bundle |
getBundle(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.
|
byte |
getByte(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.
|
Byte |
getByte(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.
|
byte[] |
getByteArray(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.
|
char |
getChar(String key)
Returns the value associated with the given key, or (char) 0 if
no mapping of the desired type exists for the given key.
|
char |
getChar(String key,
char defaultValue)
Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key.
|
char[] |
getCharArray(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.
|
CharSequence |
getCharSequence(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.
|
CharSequence |
getCharSequence(String key,
CharSequence defaultValue)
Returns the value associated with the given key, or defaultValue if
no mapping of the desired type exists for the given key or if a null
value is explicitly associatd with the given key.
|
CharSequence[] |
getCharSequenceArray(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.
|
ArrayList<CharSequence> |
getCharSequenceArrayList(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.
|
ClassLoader |
getClassLoader()
Return the ClassLoader currently associated with this Bundle.
|
float |
getFloat(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.
|
float |
getFloat(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.
|
float[] |
getFloatArray(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.
|
ArrayList<Integer> |
getIntegerArrayList(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.
|
<T extends Parcelable> |
getParcelable(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.
|
Parcelable[] |
getParcelableArray(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.
|
<T extends Parcelable> |
getParcelableArrayList(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.
|
Serializable |
getSerializable(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.
|
short |
getShort(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.
|
short |
getShort(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.
|
short[] |
getShortArray(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.
|
Size |
getSize(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.
|
SizeF |
getSizeF(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.
|
<T extends Parcelable> |
getSparseParcelableArray(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.
|
ArrayList<String> |
getStringArrayList(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.
|
void |
putAll(Bundle bundle)
Inserts all mappings from the given Bundle into this Bundle.
|
void |
putBundle(String key,
Bundle value)
Inserts a Bundle value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putByte(String key,
byte value)
Inserts a byte value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putByteArray(String key,
byte[] value)
Inserts a byte array value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putChar(String key,
char value)
Inserts a char value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putCharArray(String key,
char[] value)
Inserts a char array value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putCharSequence(String key,
CharSequence value)
Inserts a CharSequence value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putCharSequenceArray(String key,
CharSequence[] value)
Inserts a CharSequence array value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putCharSequenceArrayList(String key,
ArrayList<CharSequence> value)
Inserts an ArrayList
|
void |
putFloat(String key,
float value)
Inserts a float value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putFloatArray(String key,
float[] value)
Inserts a float array value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putIBinder(String key,
IBinder value)
Deprecated.
|
void |
putIntegerArrayList(String key,
ArrayList<Integer> value)
Inserts an ArrayList
|
void |
putParcelable(String key,
Parcelable value)
Inserts a Parcelable value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putParcelableArray(String key,
Parcelable[] value)
Inserts an array of Parcelable values into the mapping of this Bundle,
replacing any existing value for the given key.
|
void |
putParcelableArrayList(String key,
ArrayList<? extends Parcelable> value)
Inserts a List of Parcelable values into the mapping of this Bundle,
replacing any existing value for the given key.
|
void |
putParcelableList(String key,
List<? extends Parcelable> value) |
void |
putSerializable(String key,
Serializable value)
Inserts a Serializable value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putShort(String key,
short value)
Inserts a short value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putShortArray(String key,
short[] value)
Inserts a short array value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putSize(String key,
Size value)
Inserts a Size value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putSizeF(String key,
SizeF value)
Inserts a SizeF value into the mapping of this Bundle, replacing
any existing value for the given key.
|
void |
putSparseParcelableArray(String key,
SparseArray<? extends Parcelable> value)
Inserts a SparceArray of Parcelable values into the mapping of this
Bundle, replacing any existing value for the given key.
|
void |
putStringArrayList(String key,
ArrayList<String> value)
Inserts an ArrayList
|
boolean |
setAllowFds(boolean allowFds) |
void |
setClassLoader(ClassLoader loader)
Changes the ClassLoader this Bundle uses when instantiating objects.
|
String |
toString()
Reads the Parcel contents into this Bundle, typically in order for
it to be passed through an IBinder connection.
|
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.
|
containsKey, get, getDouble, getDouble, getDoubleArray, getInt, getInt, getIntArray, getLong, getLong, getLongArray, getPairValue, getString, getString, getStringArray, isEmpty, isParcelled, keySet, putAll, putDouble, putDoubleArray, putInt, putIntArray, putLong, putLongArray, putString, putStringArray, remove, sizepublic static final Bundle EMPTY
public static final Parcelable.Creator<Bundle> CREATOR
public Bundle()
public Bundle(ClassLoader loader)
loader - An explicit ClassLoader to use when instantiating objects
inside of the Bundle.public Bundle(int capacity)
capacity - the initial capacity of the Bundlepublic Bundle(Bundle b)
b - a Bundle to be copied.public Bundle(PersistableBundle b)
b - a Bundle to be copied.public static Bundle forPair(String key, String value)
public void setClassLoader(ClassLoader loader)
loader - An explicit ClassLoader to use when instantiating objects
inside of the Bundle.public ClassLoader getClassLoader()
public boolean setAllowFds(boolean allowFds)
public Object clone()
public void clear()
clear in class BaseBundlepublic void putAll(Bundle bundle)
bundle - a Bundlepublic void filterValues()
public void putByte(String key, byte value)
key - a String, or nullvalue - a bytepublic void putChar(String key, char value)
key - a String, or nullvalue - a char, or nullpublic void putShort(String key, short value)
key - a String, or nullvalue - a shortpublic void putFloat(String key, float value)
key - a String, or nullvalue - a floatpublic void putCharSequence(String key, CharSequence value)
key - a String, or nullvalue - a CharSequence, or nullpublic void putParcelable(String key, Parcelable value)
key - a String, or nullvalue - a Parcelable object, or nullpublic void putSize(String key, Size value)
key - a String, or nullvalue - a Size object, or nullpublic void putSizeF(String key, SizeF value)
key - a String, or nullvalue - a SizeF object, or nullpublic void putParcelableArray(String key, Parcelable[] value)
key - a String, or nullvalue - an array of Parcelable objects, or nullpublic void putParcelableArrayList(String key, ArrayList<? extends Parcelable> value)
key - a String, or nullvalue - an ArrayList of Parcelable objects, or nullpublic void putParcelableList(String key, List<? extends Parcelable> value)
public void putSparseParcelableArray(String key, SparseArray<? extends Parcelable> value)
key - a String, or nullvalue - a SparseArray of Parcelable objects, or nullpublic void putIntegerArrayList(String key, ArrayList<Integer> value)
key - a String, or nullvalue - an ArrayListpublic void putStringArrayList(String key, ArrayList<String> value)
key - a String, or nullvalue - an ArrayListpublic void putCharSequenceArrayList(String key, ArrayList<CharSequence> value)
key - a String, or nullvalue - an ArrayListpublic void putSerializable(String key, Serializable value)
key - a String, or nullvalue - a Serializable object, or nullpublic void putByteArray(String key, byte[] value)
key - a String, or nullvalue - a byte array object, or nullpublic void putShortArray(String key, short[] value)
key - a String, or nullvalue - a short array object, or nullpublic void putCharArray(String key, char[] value)
key - a String, or nullvalue - a char array object, or nullpublic void putFloatArray(String key, float[] value)
key - a String, or nullvalue - a float array object, or nullpublic void putCharSequenceArray(String key, CharSequence[] value)
key - a String, or nullvalue - a CharSequence array object, or nullpublic void putBundle(String key, Bundle value)
key - a String, or nullvalue - a Bundle object, or null@Deprecated public void putIBinder(String key, IBinder value)
IBinder value into the mapping of this Bundle, replacing
any existing value for the given key. Either key or value may be null.
You should be very careful when using this function. In many places where Bundles are used (such as inside of Intent objects), the Bundle can live longer inside of another process than the process that had originally created it. In that case, the IBinder you supply here will become invalid when your process goes away, and no longer usable, even if a new process is created for you later on.
key - a String, or nullvalue - an IBinder object, or nullpublic byte getByte(String key)
key - a Stringpublic Byte getByte(String key, byte defaultValue)
key - a StringdefaultValue - Value to return if key does not existpublic char getChar(String key)
key - a Stringpublic char getChar(String key, char defaultValue)
key - a StringdefaultValue - Value to return if key does not existpublic short getShort(String key)
key - a Stringpublic short getShort(String key, short defaultValue)
key - a StringdefaultValue - Value to return if key does not existpublic float getFloat(String key)
key - a Stringpublic float getFloat(String key, float defaultValue)
key - a StringdefaultValue - Value to return if key does not existpublic CharSequence getCharSequence(String key)
key - a String, or nullpublic CharSequence getCharSequence(String key, CharSequence defaultValue)
key - a String, or nulldefaultValue - Value to return if key does not exist or if a null
value is associated with the given key.public Size getSize(String key)
key - a String, or nullpublic SizeF getSizeF(String key)
key - a String, or nullpublic Bundle getBundle(String key)
key - a String, or nullpublic <T extends Parcelable> T getParcelable(String key)
key - a String, or nullpublic Parcelable[] getParcelableArray(String key)
key - a String, or nullpublic <T extends Parcelable> ArrayList<T> getParcelableArrayList(String key)
key - a String, or nullpublic <T extends Parcelable> SparseArray<T> getSparseParcelableArray(String key)
key - a String, or nullpublic Serializable getSerializable(String key)
key - a String, or nullpublic ArrayList<Integer> getIntegerArrayList(String key)
key - a String, or nullpublic ArrayList<String> getStringArrayList(String key)
key - a String, or nullpublic ArrayList<CharSequence> getCharSequenceArrayList(String key)
key - a String, or nullpublic boolean[] getBooleanArray(String key)
key - a String, or nullpublic byte[] getByteArray(String key)
key - a String, or nullpublic short[] getShortArray(String key)
key - a String, or nullpublic char[] getCharArray(String key)
key - a String, or nullpublic float[] getFloatArray(String key)
key - a String, or nullpublic CharSequence[] getCharSequenceArray(String key)
key - a String, or nullpublic int describeContents()
describeContents in interface Parcelablepublic void writeToParcel(Parcel parcel, int flags)
writeToParcel in interface Parcelableparcel - The parcel to copy this bundle to.flags - Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.