I have 3 activities, A: LoginAcitivty, B: SignupActivity, C: HomeActivity and the flow is A -> B -> C. and if I signup in the SignupActivity, then I go to HomeActivity. but there is a problem. when I click the back button on my device. I can see the LoginActivity again. So i thought first, when i click the sign-up button, i go back to LoginActivity and then in the LoginActivity, i go to HomeActivity by using Intent for the HomeActivity. and also i wrote finish() in the LoginActivity. this is my code.
<SignupActivity>
val intent = Intent(this, LoginActivity::class.java)
intent.putExtra("transfer", "transfer")
startActivity(intent)
finish()
<LoginActivity>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
if (intent.hasExtra("transfer")) {
val intent = Intent(this, HomeActivity::class.java)
startActivity(intent)
finish()
}
}
but it also doesn't work. when i click the back button on my device in the HomeActivity, i expected that the app will end. but i can still see the LoginActivity and i push back button again, then it's end. plz help me.