android start new Activity from an activity with a child

// Import necessary packages
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class ParentActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_parent)

        // Set up a click listener for the button that triggers the new activity
        val button = findViewById<Button>(R.id.button)
        button.setOnClickListener {
            // Create an Intent to specify the context (this activity) and the target activity
            val intent = Intent(this, ChildActivity::class.java)

            // Optionally, you can pass data to the new activity using extras
            intent.putExtra("key", "value")

            // Start the new activity
            startActivity(intent)
        }
    }
}

class ChildActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_child)

        // Retrieve any data passed from the parent activity
        val dataFromParent = intent.getStringExtra("key")

        // Perform actions based on the passed data or any other initialization
    }
}