Thursday, August 24, 2017

Serialization deserialization data class in kotlin example

Now I have my own blog.


If you want to pass custom data object from one activity to another in kotlin and for that purpose you need to serialize and deserialize data class.
Declare your data class like this
data class Albums(var folderNames: String, var imagePath: String, var imgCount: Int, var isVideo: Boolean) : Serializable
This is how you pass serialized data from one activity to another in kotlin
intent.putExtra("image_url_data", imagesList as Serializable)
startActivity(intent)
// imagesList variable is type ArrayList<Albums>
Now you want to receive this data class object in second activity and want to deserialize it. This is how you will do this.
var listOfImages = intent.extras.get("image_url_data") as ArrayList<Albums>

A new Blog Developine


Check out this Gallery Application written in Kotlin on playstore. soon I will open source it. stay tuned!
Gallery Android Application on Google play store written in kotlin programming language.
Back to topic :) I recommend you to use parcelable instead of serializable.
Keywords : Kotlin, Serialization, DeSerialization, data class, arraylist, custom object, activity, android example, tutorial, Gallery application android.

Kotlin Android MVP Dagger 2 Retrofit Tutorial

http://developine.com/building-android-mvp-app-in-kotlin-using-dagger-retrofit/