I'm trying to create an Intent
with ArrayList<Byte>
as extra.
So I have 3 options:
putParceableArrayList(key: String?, value: ArrayList<out Parceable!>?)
putByteArray(key: String?, value: ByteArray?)
putSerializable(key: String?, value: Serializable?)
I would prefer to not to use the 3rd option because Parceable objects are faster than Serializable ones (Android: Difference between Parcelable and Serializable?).
Discarding this option, I want to use the first option because I need this object as an ArrayList and not as a native array bytes[]
(ByteArray
on Kotlin).
The problem is that Byte object is native, so it does not implements Parceable. So that, I can't use the first option because it requires ArrayList<out Parceable>
.
The best option I found is to transform the ArrayList
to ByteArray
and transform it back to an ArrayList
when I unpack the extras like so:
intent.extras?.putByteArray(event, response.toByteArray())
[...]
var list = Arrays.asList(intent.extras?.getByteArray(event))
Which is the best option? Thank you!