Bundle
class Bundle : BaseBundle, Cloneable, Parcelable
kotlin.Any | ||
↳ | android.os.BaseBundle | |
↳ | android.os.Bundle |
A mapping from String keys to various Parcelable
values.
Warning: Note that Bundle
is a lazy container and as such it does NOT implement equals(java.lang.Object)
or hashCode()
.
Summary
Inherited constants | |
---|---|
Public constructors | |
---|---|
Bundle() Constructs a new, empty Bundle. |
|
Bundle(loader: ClassLoader!) Constructs a new, empty Bundle that uses a specific ClassLoader for instantiating Parcelable and Serializable objects. |
|
Constructs a new, empty Bundle sized to hold the given number of elements. |
|
Constructs a Bundle containing a copy of the mappings from the given Bundle. |
|
Bundle(b: PersistableBundle!) Constructs a Bundle containing a copy of the mappings from the given PersistableBundle. |
Public methods | |
---|---|
Unit |
clear() Removes all elements from the mapping of this Bundle. |
Any |
clone() Clones the current Bundle. |
Bundle! |
deepCopy() Make a deep copy of the given bundle. |
Int |
Report the nature of this Parcelable's contents |
IBinder? |
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? |
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 |
Returns the value associated with the given key, or (byte) 0 if no mapping of the desired type exists for the given key. |
Byte! |
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. |
ByteArray? |
getByteArray(key: String?) 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 |
Returns the value associated with the given key, or (char) 0 if no mapping of the desired type exists for the given key. |
Char |
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. |
CharArray? |
getCharArray(key: String?) 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(key: String?) 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(key: String?, defaultValue: CharSequence!) 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. |
Array<CharSequence!>? |
getCharSequenceArray(key: String?) 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(key: String?) 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! |
Return the ClassLoader currently associated with this Bundle. |
Float |
Returns the value associated with the given key, or 0. |
Float |
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. |
FloatArray? |
getFloatArray(key: String?) 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<Int!>? |
getIntegerArrayList(key: String?) 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? |
getParcelable(key: String?) Returns the value associated with the given key, or |
T? |
getParcelable(key: String?, clazz: Class<T>) Returns the value associated with the given key or
|
Array<Parcelable!>? |
getParcelableArray(key: String?) Returns the value associated with the given key, or |
Array<T>? |
getParcelableArray(key: String?, clazz: Class<T>) Returns the value associated with the given key, or
|
ArrayList<T>? |
getParcelableArrayList(key: String?) Returns the value associated with the given key, or |
ArrayList<T>? |
getParcelableArrayList(key: String?, clazz: Class<out T>) Returns the value associated with the given key, or
|
Serializable? |
getSerializable(key: String?) 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? |
getSerializable(key: String?, clazz: Class<T>) Returns the value associated with the given key, or
|
Short |
Returns the value associated with the given key, or (short) 0 if no mapping of the desired type exists for the given key. |
Short |
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key. |
ShortArray? |
getShortArray(key: String?) 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? |
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? |
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. |
SparseArray<T>? |
getSparseParcelableArray(key: String?) 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. |
SparseArray<T>? |
getSparseParcelableArray(key: String?, clazz: Class<out T>) Returns the value associated with the given key, or
|
ArrayList<String!>? |
getStringArrayList(key: String?) 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. |
Boolean |
Reports whether the bundle contains any parcelled file descriptors. |
Unit |
Inserts all mappings from the given Bundle into this Bundle. |
Unit |
Inserts an |
Unit |
Inserts a Bundle value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
Inserts a byte value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putByteArray(key: String?, value: ByteArray?) Inserts a byte array value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
Inserts a char value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putCharArray(key: String?, value: CharArray?) Inserts a char array value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putCharSequence(key: String?, value: CharSequence?) Inserts a CharSequence value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putCharSequenceArray(key: String?, value: Array<CharSequence!>?) Inserts a CharSequence array value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putCharSequenceArrayList(key: String?, value: ArrayList<CharSequence!>?) 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. |
Unit |
Inserts a float value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putFloatArray(key: String?, value: FloatArray?) Inserts a float array value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putIntegerArrayList(key: String?, value: ArrayList<Int!>?) 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. |
Unit |
putParcelable(key: String?, value: Parcelable?) Inserts a Parcelable value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putParcelableArray(key: String?, value: Array<Parcelable!>?) Inserts an array of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putParcelableArrayList(key: String?, value: ArrayList<out Parcelable!>?) Inserts a List of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putSerializable(key: String?, value: Serializable?) Inserts a Serializable value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
Inserts a short value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putShortArray(key: String?, value: ShortArray?) Inserts a short array value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
Inserts a Size value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
Inserts a SizeF value into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putSparseParcelableArray(key: String?, value: SparseArray<out Parcelable!>?) Inserts a SparceArray of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key. |
Unit |
putStringArrayList(key: String?, value: ArrayList<String!>?) 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. |
Unit |
readFromParcel(parcel: Parcel!) Reads the Parcel contents into this Bundle, typically in order for it to be passed through an IBinder connection. |
Unit |
Removes any entry with the given key from the mapping of this Bundle. |
Unit |
setClassLoader(loader: ClassLoader!) Changes the ClassLoader this Bundle uses when instantiating objects. |
String |
toString() Returns a string representation of the |
Unit |
writeToParcel(parcel: Parcel, flags: Int) Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection. |
Inherited functions | |
---|---|
Properties | |
---|---|
static Parcelable.Creator<Bundle!> | |
static Bundle! |
An unmodifiable |
Public constructors
Bundle
Bundle(loader: ClassLoader!)
Constructs a new, empty Bundle that uses a specific ClassLoader for instantiating Parcelable and Serializable objects.
Parameters | |
---|---|
loader |
ClassLoader!: An explicit ClassLoader to use when instantiating objects inside of the Bundle. |
Bundle
Bundle(capacity: Int)
Constructs a new, empty Bundle sized to hold the given number of elements. The Bundle will grow as needed.
Parameters | |
---|---|
capacity |
Int: the initial capacity of the Bundle |
Bundle
Bundle(b: Bundle!)
Constructs a Bundle containing a copy of the mappings from the given Bundle. Does only a shallow copy of the original Bundle -- see deepCopy()
if that is not what you want.
Parameters | |
---|---|
b |
Bundle!: a Bundle to be copied. |
See Also
Bundle
Bundle(b: PersistableBundle!)
Constructs a Bundle containing a copy of the mappings from the given PersistableBundle. Does only a shallow copy of the PersistableBundle -- see PersistableBundle#deepCopy()
if you don't want that.
Parameters | |
---|---|
b |
PersistableBundle!: a PersistableBundle to be copied. |
Public methods
clone
fun clone(): Any
Clones the current Bundle. The internal map is cloned, but the keys and values to which it refers are copied by reference.
Return | |
---|---|
Any |
a clone of this instance. |
Exceptions | |
---|---|
java.lang.CloneNotSupportedException |
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned. |
deepCopy
fun deepCopy(): Bundle!
Make a deep copy of the given bundle. Traverses into inner containers and copies them as well, so they are not shared across bundles. Will traverse in to Bundle
, PersistableBundle
, ArrayList
, and all types of primitive arrays. Other types of objects (such as Parcelable or Serializable) are referenced as-is and not copied in any way.
describeContents
fun describeContents(): Int
Report the nature of this Parcelable's contents
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
getBinder
fun getBinder(key: String?): IBinder?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
IBinder? |
an IBinder value, or null |
getBundle
fun getBundle(key: String?): Bundle?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
Bundle? |
a Bundle value, or null |
getByte
fun getByte(key: String!): Byte
Returns the value associated with the given key, or (byte) 0 if no mapping of the desired type exists for the given key.
Parameters | |
---|---|
key |
String!: a String |
Return | |
---|---|
Byte |
a byte value |
getByte
fun getByte(
key: String!,
defaultValue: Byte
): Byte!
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.
Parameters | |
---|---|
key |
String!: a String |
defaultValue |
Byte: Value to return if key does not exist |
Return | |
---|---|
Byte! |
a byte value |
getByteArray
fun getByteArray(key: String?): ByteArray?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
ByteArray? |
a byte[] value, or null |
getChar
fun getChar(key: String!): Char
Returns the value associated with the given key, or (char) 0 if no mapping of the desired type exists for the given key.
Parameters | |
---|---|
key |
String!: a String |
Return | |
---|---|
Char |
a char value |
getChar
fun getChar(
key: String!,
defaultValue: Char
): Char
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.
Parameters | |
---|---|
key |
String!: a String |
defaultValue |
Char: Value to return if key does not exist |
Return | |
---|---|
Char |
a char value |
getCharArray
fun getCharArray(key: String?): CharArray?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
CharArray? |
a char[] value, or null |
getCharSequence
fun getCharSequence(key: String?): CharSequence?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
CharSequence? |
a CharSequence value, or null |
getCharSequence
fun getCharSequence(
key: String?,
defaultValue: CharSequence!
): CharSequence!
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.
Parameters | |
---|---|
key |
String?: a String, or null |
defaultValue |
CharSequence!: Value to return if key does not exist or if a null value is associated with the given key. |
Return | |
---|---|
CharSequence! |
the CharSequence value associated with the given key, or defaultValue if no valid CharSequence object is currently mapped to that key. |
getCharSequenceArray
fun getCharSequenceArray(key: String?): Array<CharSequence!>?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
Array<CharSequence!>? |
a CharSequence[] value, or null |
getCharSequenceArrayList
fun getCharSequenceArrayList(key: String?): ArrayList<CharSequence!>?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
ArrayList<CharSequence!>? |
an ArrayList value, or null |
getClassLoader
fun getClassLoader(): ClassLoader!
Return the ClassLoader currently associated with this Bundle.
getFloat
fun getFloat(key: String!): Float
Returns the value associated with the given key, or 0.0f if no mapping of the desired type exists for the given key.
Parameters | |
---|---|
key |
String!: a String |
Return | |
---|---|
Float |
a float value |
getFloat
fun getFloat(
key: String!,
defaultValue: Float
): Float
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.
Parameters | |
---|---|
key |
String!: a String |
defaultValue |
Float: Value to return if key does not exist |
Return | |
---|---|
Float |
a float value |
getFloatArray
fun getFloatArray(key: String?): FloatArray?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
FloatArray? |
a float[] value, or null |
getIntegerArrayList
fun getIntegerArrayList(key: String?): ArrayList<Int!>?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
ArrayList<Int!>? |
an ArrayList value, or null |
getParcelable
fun <T : Parcelable!>getParcelable(key: String?): T?
Deprecated: Use the type-safer getParcelable(java.lang.String,java.lang.Class)
starting from Android Build.VERSION_CODES#TIRAMISU
.
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.
Note: if the expected value is not a class provided by the Android platform, you must call setClassLoader(java.lang.ClassLoader)
with the proper ClassLoader
first. Otherwise, this method might throw an exception or return null
.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
T? |
a Parcelable value, or null |
getParcelable
fun <T : Any!> getParcelable(
key: String?,
clazz: Class<T>
): T?
Returns the value associated with the given key or null
if:
- No mapping of the desired type exists for the given key.
- A
null
value is explicitly associated with the key. - The object is not of type
clazz
.
Note: if the expected value is not a class provided by the Android platform, you must call setClassLoader(java.lang.ClassLoader)
with the proper ClassLoader
first. Otherwise, this method might throw an exception or return null
.
Warning: the class that implements Parcelable
has to be the immediately enclosing class of the runtime type of its CREATOR field (that is, Class#getEnclosingClass()
has to return the parcelable implementing class), otherwise this method might throw an exception. If the Parcelable class does not enclose the CREATOR, use the deprecated getParcelable(java.lang.String)
instead.
Parameters | |
---|---|
key |
String?: a String, or null |
clazz |
Class<T>: The type of the object expected This value cannot be null . |
Return | |
---|---|
T? |
a Parcelable value, or null |
getParcelableArray
fungetParcelableArray(key: String?): Array<Parcelable!>?
Deprecated: Use the type-safer getParcelableArray(java.lang.String,java.lang.Class)
starting from Android Build.VERSION_CODES#TIRAMISU
.
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.
Note: if the expected value is not a class provided by the Android platform, you must call setClassLoader(java.lang.ClassLoader)
with the proper ClassLoader
first. Otherwise, this method might throw an exception or return null
.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
Array<Parcelable!>? |
a Parcelable[] value, or null |
getParcelableArray
fun <T : Any!> getParcelableArray(
key: String?,
clazz: Class<T>
): Array<T>?
Returns the value associated with the given key, or null
if:
- No mapping of the desired type exists for the given key.
- A
null
value is explicitly associated with the key. - The object is not of type
clazz
.
Note: if the expected value is not a class provided by the Android platform, you must call setClassLoader(java.lang.ClassLoader)
with the proper ClassLoader
first. Otherwise, this method might throw an exception or return null
.
Warning: if the list contains items implementing the Parcelable
interface, the class that implements Parcelable
has to be the immediately enclosing class of the runtime type of its CREATOR field (that is, Class#getEnclosingClass()
has to return the parcelable implementing class), otherwise this method might throw an exception. If the Parcelable class does not enclose the CREATOR, use the deprecated getParcelableArray(java.lang.String)
instead.
Parameters | |
---|---|
key |
String?: a String, or null |
clazz |
Class<T>: The type of the items inside the array. This is only verified when unparceling. This value cannot be null . |
Return | |
---|---|
Array<T>? |
a Parcelable[] value, or null |
getParcelableArrayList
fun <T : Parcelable!>getParcelableArrayList(key: String?): ArrayList<T>?
Deprecated: Use the type-safer getParcelable(java.lang.String,java.lang.Class)
starting from Android Build.VERSION_CODES#TIRAMISU
.
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.
Note: if the expected value is not a class provided by the Android platform, you must call setClassLoader(java.lang.ClassLoader)
with the proper ClassLoader
first. Otherwise, this method might throw an exception or return null
.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
ArrayList<T>? |
an ArrayList value, or null |
getParcelableArrayList
fun <T : Any!> getParcelableArrayList(
key: String?,
clazz: Class<out T>
): ArrayList<T>?
Returns the value associated with the given key, or null
if:
- No mapping of the desired type exists for the given key.
- A
null
value is explicitly associated with the key. - The object is not of type
clazz
.
Note: if the expected value is not a class provided by the Android platform, you must call setClassLoader(java.lang.ClassLoader)
with the proper ClassLoader
first. Otherwise, this method might throw an exception or return null
.
Warning: if the list contains items implementing the Parcelable
interface, the class that implements Parcelable
has to be the immediately enclosing class of the runtime type of its CREATOR field (that is, Class#getEnclosingClass()
has to return the parcelable implementing class), otherwise this method might throw an exception. If the Parcelable class does not enclose the CREATOR, use the deprecated getParcelableArrayList(java.lang.String)
instead.
Parameters | |
---|---|
key |
String?: a String, or null |
clazz |
Class<out T>: The type of the items inside the array list. This is only verified when unparceling. This value cannot be null . |
Return | |
---|---|
ArrayList<T>? |
an ArrayList value, or null |
getSerializable
fungetSerializable(key: String?): Serializable?
Deprecated: Use the type-safer getSerializable(java.lang.String,java.lang.Class)
starting from Android Build.VERSION_CODES#TIRAMISU
.
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
Serializable? |
a Serializable value, or null |
getSerializable
fun <T : Serializable!> getSerializable(
key: String?,
clazz: Class<T>
): T?
Returns the value associated with the given key, or null
if:
- No mapping of the desired type exists for the given key.
- A
null
value is explicitly associated with the key. - The object is not of type
clazz
.
Parameters | |
---|---|
key |
String?: a String, or null |
clazz |
Class<T>: The expected class of the returned type This value cannot be null . |
Return | |
---|---|
T? |
a Serializable value, or null |
getShort
fun getShort(key: String!): Short
Returns the value associated with the given key, or (short) 0 if no mapping of the desired type exists for the given key.
Parameters | |
---|---|
key |
String!: a String |
Return | |
---|---|
Short |
a short value |
getShort
fun getShort(
key: String!,
defaultValue: Short
): Short
Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.
Parameters | |
---|---|
key |
String!: a String |
defaultValue |
Short: Value to return if key does not exist |
Return | |
---|---|
Short |
a short value |
getShortArray
fun getShortArray(key: String?): ShortArray?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
ShortArray? |
a short[] value, or null |
getSize
fun getSize(key: String?): Size?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
Size? |
a Size value, or null |
getSizeF
fun getSizeF(key: String?): SizeF?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
SizeF? |
a Size value, or null |
getSparseParcelableArray
fun <T : Parcelable!>getSparseParcelableArray(key: String?): SparseArray<T>?
Deprecated: Use the type-safer getSparseParcelableArray(java.lang.String,java.lang.Class)
starting from Android Build.VERSION_CODES#TIRAMISU
.
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
SparseArray<T>? |
a SparseArray of T values, or null |
getSparseParcelableArray
fun <T : Any!> getSparseParcelableArray(
key: String?,
clazz: Class<out T>
): SparseArray<T>?
Returns the value associated with the given key, or null
if:
- No mapping of the desired type exists for the given key.
- A
null
value is explicitly associated with the key. - The object is not of type
clazz
.
Warning: if the list contains items implementing the Parcelable
interface, the class that implements Parcelable
has to be the immediately enclosing class of the runtime type of its CREATOR field (that is, Class#getEnclosingClass()
has to return the parcelable implementing class), otherwise this method might throw an exception. If the Parcelable class does not enclose the CREATOR, use the deprecated getSparseParcelableArray(java.lang.String)
instead.
Parameters | |
---|---|
key |
String?: a String, or null |
clazz |
Class<out T>: The type of the items inside the sparse array. This is only verified when unparceling. This value cannot be null . |
Return | |
---|---|
SparseArray<T>? |
a SparseArray of T values, or null |
getStringArrayList
fun getStringArrayList(key: String?): ArrayList<String!>?
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.
Parameters | |
---|---|
key |
String?: a String, or null |
Return | |
---|---|
ArrayList<String!>? |
an ArrayList value, or null |
hasFileDescriptors
fun hasFileDescriptors(): Boolean
Reports whether the bundle contains any parcelled file descriptors.
putAll
fun putAll(bundle: Bundle!): Unit
Inserts all mappings from the given Bundle into this Bundle.
Parameters | |
---|---|
bundle |
Bundle!: a Bundle |
putBinder
fun putBinder(
key: String?,
value: IBinder?
): Unit
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.
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
IBinder?: an IBinder object, or null |
putBundle
fun putBundle(
key: String?,
value: Bundle?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Bundle?: a Bundle object, or null |
putByte
fun putByte(
key: String?,
value: Byte
): Unit
Inserts a byte value into the mapping of this Bundle, replacing any existing value for the given key.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Byte: a byte |
putByteArray
fun putByteArray(
key: String?,
value: ByteArray?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
ByteArray?: a byte array object, or null |
putChar
fun putChar(
key: String?,
value: Char
): Unit
Inserts a char value into the mapping of this Bundle, replacing any existing value for the given key.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Char: a char |
putCharArray
fun putCharArray(
key: String?,
value: CharArray?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
CharArray?: a char array object, or null |
putCharSequence
fun putCharSequence(
key: String?,
value: CharSequence?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
CharSequence?: a CharSequence, or null |
putCharSequenceArray
fun putCharSequenceArray(
key: String?,
value: Array<CharSequence!>?
): Unit
Inserts a CharSequence array value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Array<CharSequence!>?: a CharSequence array object, or null |
putCharSequenceArrayList
fun putCharSequenceArrayList(
key: String?,
value: ArrayList<CharSequence!>?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
ArrayList<CharSequence!>?: an ArrayList object, or null |
putFloat
fun putFloat(
key: String?,
value: Float
): Unit
Inserts a float value into the mapping of this Bundle, replacing any existing value for the given key.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Float: a float |
putFloatArray
fun putFloatArray(
key: String?,
value: FloatArray?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
FloatArray?: a float array object, or null |
putIntegerArrayList
fun putIntegerArrayList(
key: String?,
value: ArrayList<Int!>?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
ArrayList<Int!>?: an ArrayList object, or null |
putParcelable
fun putParcelable(
key: String?,
value: Parcelable?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Parcelable?: a Parcelable object, or null |
putParcelableArray
fun putParcelableArray(
key: String?,
value: Array<Parcelable!>?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Array<Parcelable!>?: an array of Parcelable objects, or null |
putParcelableArrayList
fun putParcelableArrayList(
key: String?,
value: ArrayList<out Parcelable!>?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
ArrayList<out Parcelable!>?: an ArrayList of Parcelable objects, or null |
putSerializable
fun putSerializable(
key: String?,
value: Serializable?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Serializable?: a Serializable object, or null |
putShort
fun putShort(
key: String?,
value: Short
): Unit
Inserts a short value into the mapping of this Bundle, replacing any existing value for the given key.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Short: a short |
putShortArray
fun putShortArray(
key: String?,
value: ShortArray?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
ShortArray?: a short array object, or null |
putSize
fun putSize(
key: String?,
value: Size?
): Unit
Inserts a Size value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
Size?: a Size object, or null |
putSizeF
fun putSizeF(
key: String?,
value: SizeF?
): Unit
Inserts a SizeF value into the mapping of this Bundle, replacing any existing value for the given key. Either key or value may be null.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
SizeF?: a SizeF object, or null |
putSparseParcelableArray
fun putSparseParcelableArray(
key: String?,
value: SparseArray<out Parcelable!>?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
SparseArray<out Parcelable!>?: a SparseArray of Parcelable objects, or null |
putStringArrayList
fun putStringArrayList(
key: String?,
value: ArrayList<String!>?
): Unit
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.
Parameters | |
---|---|
key |
String?: a String, or null |
value |
ArrayList<String!>?: an ArrayList object, or null |
readFromParcel
fun readFromParcel(parcel: Parcel!): Unit
Reads the Parcel contents into this Bundle, typically in order for it to be passed through an IBinder connection.
Parameters | |
---|---|
parcel |
Parcel!: The parcel to overwrite this bundle from. |
remove
fun remove(key: String!): Unit
Removes any entry with the given key from the mapping of this Bundle.
Parameters | |
---|---|
key |
String!: a String key |
setClassLoader
fun setClassLoader(loader: ClassLoader!): Unit
Changes the ClassLoader this Bundle uses when instantiating objects.
Parameters | |
---|---|
loader |
ClassLoader!: An explicit ClassLoader to use when instantiating objects inside of the Bundle. |
toString
fun toString(): String
Returns a string representation of the Bundle
that may be suitable for debugging. It won't print the internal map if its content hasn't been unparcelled.
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
fun writeToParcel(
parcel: Parcel,
flags: Int
): Unit
Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.
Parameters | |
---|---|
dest |
The Parcel in which the object should be written. This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
parcel |
Parcel: The parcel to copy this bundle to. |