简体   繁体   中英

Android: Pass serialisable object data to another activity

I have a class, which contains an array list of another object, when I try to pass the data to another activity, it does not pass other objects like my array list Appointment, how to do? Here are my classes:

open class Customer(var name: String = "") : Serializable{
    var appointments: List<Appointment>? = null
}

And:

class Appointment(val id: String?, val title: String?, val date: Date) : Serializable { 
}

To pass data:

putExtra("customer", customer)

To get data:

intent.getSerializableExtra("customer") as Customer?

It works, but the list of appointments is not sent, only the customer, why?

The list is not null before doing the startActivity, but when I do the getIntent I get the null list, it was not sent

List doesn't implement Serializable .

How about try to use Arraylist .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM