In an Android application, how do you start a new activity (GUI) when a button in another activity is clicked, and how do you pass data between these two activities?
// In Kotlin , you can do as /* In First Activity, let in activity layout there is button which has id as button. Suppose I have to pass data as String type from one activity to another */
val btn = findViewById
// In Second Activity, you can get data from another activity as
val name = intent.getStringExtra("KEY")
/* Suppose you have to pass a Custom Object then it should be Parcelable. let there is class Collage type which I have to pass from one activity to another */
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
@Parcelize
class Collage(val name: String, val mobile: String, val email: String) : Parcelable
/* Activity First , let here data is Collage type. which I have to pass to another activity. */
val btn = findViewById
// then from second Activity we will get as
val item = intent.extras?.getParcelable("KEY")