Search code examples
exceptionkotlinadapter

Parcelable encountered IOException writing serializable object (name = [Lcom.example.gaeo.Model_responsable;)


I have this exception when trying to call an activity from an adapter

First class :

class  Model_responsable (val adressePrincipale: String,
                         val emailPrincipal: String,
                         val telephonePrincipal: String,
                         val siteWebPrincipal: String,
                         val nom: String,
                         val fonction: String,
                         val commentaires: Array<Model_commentaire>)

Second class :

class Model_commentaire ( val contenu: String,
                          val importance: String)

My code in the adapter

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
    holder.nom?.text = responsables[position].nom
    holder.fonction?.text = responsables[position].fonction
    holder.telephone?.text = responsables[position].telephonePrincipal
    holder.email?.text = responsables[position].emailPrincipal
    holder.adresse?.text = responsables[position].adressePrincipale
    if (10 >0 )
        holder.commentaires?.visibility = View.VISIBLE
    else
        holder.commentaires?.visibility = View.GONE

    // Mise en place de clicks

     holder.commentaires?.setOnClickListener() {
        var intent = Intent(it.context, Activity_commentaires::class.java)
        startActivity(it.context, intent, null)
    }
}

My empty activity should popup. instead, it shows up, disapears and I have this error

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = [Lcom.example.gaeo.Model_responsable;)


Solution

  • You're absolutly right, it works fine with the Serializable interface. thanks a lot