I want to pass a variable through a button from one class to another using intents.
This is the code I have so far:
Class A:
val i = Intent (this, ClassB::class.java)
intent.putExtra("IS_BLUE", 1)
startActivity(i)
to class B:
val isBlue: Long = intent . getLongExtra("IS_BLUE", 0)
I am trying to write an if statement to check if it equals 1 or 0. Since the default value is 0 it keeps taking that as the variable instead of what I put it to be in the previous class and going for the else statement.
if (isBlue.equals(1)) { ... } else { ... }
I might have gotten my types wrong but when I tried with
intent.getIntExtra("IS_BLUE", 0)
I was getting the same issues and some errors in my if statement as well. I am getting no errors and I can run my app fine, I just can't get the variable to pass. Please help.