Kotlin : Intent extra problem

Hello

I have a little problem with one activity.
The intent extra always return the same value.

In my first activity i call the DiListActivity with two extra
extra_clo_index = 1 or 0
extra_niv_index = 44 in my exemple

var clot: Int = 0

BTTravaux.setOnClickListener {
clot = 0
val intent = Intent(this, DiListActivity::class.java)
//Je passe en paramettre le fait qu’il soit pas cloture
intent.putExtra(DiListActivity.extra_clo_index, clot)
intent.putExtra(DiListActivity.extra_niv_index, extraniv)
startActivity(intent)
}
BTCloture.setOnClickListener {
clot = 1
val intent = Intent(this, DiListActivity::class.java)
intent.putExtra(DiListActivity.extra_clo_index, clot)
intent.putExtra(DiListActivity.extra_niv_index, extraniv)
startActivity(intent)

In the second activity i have

companion object {

    val extra_niv_index = "0"
    val extra_clo_index = "0"
}
 var extraniv:Int = intent.getIntExtra(extra_niv_index,0)
 var extraclo:Int = intent.getIntExtra(extra_clo_index,0)

The extra_niv_index return 44
The extra_clo_index return 44

I don’t understand what is the problem.

Any idea ?

Thanks

I believe your issue is that the key for getting the values are the same.

companion object  {
   val extra_niv_index = "extra_niv_index"
   val extra_clo_index = "extra_clo_index"
}

var extraniv:Int = intent.getIntExtra(extra_niv_index,0)
var extraclo:Int = intent.getIntExtra(extra_clo_index,0)

This should work because getIntExtra((Key) String, (Default Value) Int).
By using the same key, you are just replacing the value.