public static final Parcelable.Creator CREATOR
= new Parcelable.Creator() {
public MyParcelable createFromParcel(Parcel in) {
return new MyParcelable(in);
public MyParcelable[] newArray(int size) {
return new MyParcelable[size];
private MyParcelable(Parcel in) {
mData = in.readInt();
I’m not really a fan of this type of implementation because it will make my data class more difficult to read and confusing.
Typically it is complicated to pass a list of objects between Activities. But lately in Kotlin all you have to do is simple.
First, in your data class you implement Serializable.
@Entity
data class ItemCount(
@ColumnInfo(name = "id") val itemID: Int,
@ColumnInfo(name = "name") val name: String
): Serializable {
@PrimaryKey(autoGenerate = true) var id: Int? = null
Enter fullscreen modeExit fullscreen mode
val intent = Intent(this, FinishScanActivity::class.java)
intent.putExtra("list", listItemCount as Serializable)
startActivity(intent)
Enter fullscreen modeExit fullscreen mode
Built on Forem — the open source software that powers DEV and other inclusive communities.